zoukankan
html css js c++ java
弹出层组件
<style> *{margin:0;padding:0} #tinymask{ position: absolute; top: 0; left: 0; height: 100%; 100%; z-index: 1500; background-color:#000; opacity:0; display:none; } #tinybox{ display:none; background-color:#fff; padding:10px; z-index: 1600; } </style> <script> var Class = { create: function() { return function() { this.initialize.apply(this, arguments); } } } var extend = function(destination, source) { for (var property in source) { destination[property] = source[property]; } return destination; } var Popup = Class.create();//我们的富文本编辑器类 Popup.prototype = { initialize:function(options){ this.setOptions(options); this.createpup(options); }, setOptions:function(options){ this.options = { //这里集中设置默认属性 "opacity":30 } extend(this.options, options || {});//这里是用来重写默认属性 }, ID:function(id){return document.getElementById(id) },//getElementById的快捷方式 TN:function(tn){ return document.getElementsByTagName(tn) },//getElementsByTagName的快捷方式 CE:function(s){ return document.createElement(s)},//createElement的快捷方式 height:function(){ return Math.max(document.documentElement.scrollHeight|| document.body.scrollHeight,document.documentElement.clientHeight|| document.body.clientHeight) ; }, cheight:function(){ return document.documentElement.clientHeight|| document.body.clientHeight; }, function(){ return Math.max(document.documentElement.scrollWidth|| document.body.scrollWidth,document.documentElement.clientWidth|| document.body.clientWidth) ; }, hide:function(t,op,end,speed){ this.alpha(t,op,end,speed); }, show:function(t,op,end,speed){ this.alpha(t,op,end,speed) }, alpha:function(t,op,end,speed) { $=this; var k=op; var b=end; if(end==0){ document.body.removeChild($.ID('tinybox')); } t.si = setInterval(function () { if(op) speed = Math.ceil(op /speed); else speed = Math.ceil(end /speed); //if(speed=0) speed=1; op = op +speed; console.log(speed) if(k==0&&op>=end||(b==0&&op<=end)){ document.getElementById('tinymask').style.opacity = (op / 100); console.log(end); if(end){ document.getElementById('tinymask').style.display="block"; document.getElementById('tinybox').style.display="block"; }else{ document.body.removeChild($.ID('tinymask')); } clearInterval(t.si) } }, 20) }, resize:function(){ var $ = this; $.ID('tinymask').style.width=$.width()+'px'; $.ID('tinymask').style.height=$.height()+'px'; }, popPosition:function(e){ e.style.position="absolute"; e.style.left=(this.width()/2- e.offsetWidth/2)+"px"; e.style.top=(this.cheight()/2- e.offsetHeight/2)+"px"; }, createpup:function(t){ var k=null; var pw,ph; var $ = this; var opacity= t.opacity; console.log(opacity); var p=document.createElement('div'); p.id='tinybox'; var m=document.createElement('div'); m.id='tinymask'; var b=document.createElement('div'); b.id='tinycontent'; m.style.width=$.width()+"px"; m.style.height=$.height()+"px"; // m.style.opacity=opacity/100; //m.style.filter='alpha(opacity:'+opacity+')'; b.innerHTML=t.content; document.body.appendChild(m); document.body.appendChild(p); $.show(p,0,opacity,5); p.appendChild(b); ph= t.Pheight?t.Pheight+"px":""; pw= t.Pwidth?t.Pwidth+"px":""; p.style.height=ph; p.style.width=pw; $.popPosition(p); m.onclick=function(){ $.hide(p,opacity,0,-5); } window.onresize = function(){ $.resize(); $.popPosition(p); } } } window.onload = function(){ document.getElementById("btnc").onclick=function(){ new Popup({"opacity":50,"content":"<img src='http://images.cnblogs.com/cnblogs_com/heyinwangchuan/928444/o_u=467872920,427253626_fm=58.jpg'>"}); } } </script> <button id="btnc">运行</button>
运行
查看全文
相关阅读:
常用的Intent.Action(转)
Android存储--SharedPreferences
Linux虚拟机网络配置
SSH的两种登录方式以及配置
Docker学习のC/S模式
Docker学习のDocker镜像
Docker学习のDocker中部署静态页网站
Docker学习のWindows下如何访问Docker本身的虚拟机
Docker学习のDocker的简单应用
Docker学习の更改Docker的目录
原文地址:https://www.cnblogs.com/heyinwangchuan/p/6136002.html
最新文章
highcharts图表的常见操作
js之面向对象
js之作用域
luogu P6583 回首过去 简单数论变换 简单容斥
5.29 省选模拟赛 树形图求和 有向图矩阵树定理 高斯消元 行列式
CF EC 87 div2 1354 C2 Not So Simple Polygon Embedding 计算几何 结论
EC R 87 div2 D. Multiset 线段树 树状数组 二分
5.13 省选模拟赛 优雅的绽放吧,墨染樱花 多项式 prufer序列 计数 dp
luogu P6570 [NOI Online #3 提高组]优秀子序列 二进制 dp
牛客练习赛64 如果我让你查回文你还爱我吗 线段树 树状数组 manacher 计数 区间本质不同回文串个数
热门文章
牛客练习赛64 红色的樱花 exgcd 贪心
5.20 省选模拟赛 求和 组合数的性质 EGF CRT
Spring+hibernate+JSP实现Piano的数据库操作---2.Controller+Service+Dao
Spring+hibernate+JSP实现Piano的数据库操作---1.目录结构+展示
transaction already active
Spring+hibernate无法执行更新操作
SpringBoot实现前后端数据交互、json数据交互、Controller接收参数的几种常用方式
Spring JPA实现增删改查
IDEA插件
LayoutInflater作用及使用
Copyright © 2011-2022 走看看