打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
js制作一个简单的div弹窗:

演示地址:http://demo.jb51.net/js/2015/jquery-simple-alert-style-demo/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>弹出层</title><script src="jquery-1.6.2.min.js" type="text/javascript"></script><style>.black_overlay{ display: none; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:1001; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80);}.white_content { display: none; position: absolute; top: 10%; left: 10%; width: 80%; height: 80%; border: 16px solid lightblue; background-color: white; z-index:1002; overflow: auto;}.white_content_small { display: none; position: absolute; top: 20%; left: 30%; width: 40%; height: 50%; border: 16px solid lightblue; background-color: white; z-index:1002; overflow: auto;}</style><script type="text/javascript">//弹出隐藏层function ShowDiv(show_div,bg_div){ document.getElementById(show_div).style.display='block'; document.getElementById(bg_div).style.display='block' ; var bgdiv = document.getElementById(bg_div); bgdiv.style.width = document.body.scrollWidth;  // bgdiv.style.height = $(document).height(); $("#"+bg_div).height($(document).height());};//关闭弹出层function CloseDiv(show_div,bg_div){ document.getElementById(show_div).style.display='none'; document.getElementById(bg_div).style.display='none';};</script></head><body><input id="Button1" type="button" value="点击弹出层" onclick="ShowDiv('MyDiv','fade')" /><!--弹出层时背景层DIV--><div id="fade" class="black_overlay"></div> <div id="MyDiv" class="white_content">  <div style="text-align: right; cursor: default; height: 40px;">   <span style="font-size: 16px;" onclick="CloseDiv('MyDiv','fade')">关闭</span>  </div>  目前来说,我还是喜欢这个自己改造的弹出层。自己在项目中也用的是这个。 </div></body></html>



                    
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
css 背景透明,文字不透明,alpha滤镜,opacity,position:relat...
div代替select标签
又到周末了,我们一起来研究【浏览器如何检测是否安装app】吧
CSS+JS折角广告代码
display:none与visibility:hidden不同的结果
js通过封装div方式弹出div窗体
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服