js与css实现弹出层覆盖整个页面的方法

本文实例讲述了js与css实现弹出层覆盖整个页面方法分享给大家供大家参考。具体实现方法如下:

弹出层透明背景加框的常用样式和结构如下:

代码如下:
display:none; } .alertMessageDivBorder{ position:fixed; _position:absolute; width:750px; height:370px; left:50%; top:50%; margin:-185px 0 0 -375px; background:#000; filter:alpha(opacity=30); -moz-opacity:0.3; opacity:0.3; z-index:98; display:none; } .alertMessageDiv{ position:fixed; _position:absolute; width:730px; height:350px; left:50%; top:50%; margin:-175px 0 0 -365px; background:#fff; z-index:99; display:none; font-size:14px; }

弹出层背景覆盖整个网页的方法

1.css方法

代码如下:
display:none; }

2.js方法

代码如下:
display:none; }

var bgWidth = document.body.clientWidth + 'px',   bgHeight = document.body.clientHeight + 'px',   alertBgNode = $('.alertMessageBg'); alertBgNode.css({'width':bgWidth,'height':bgHeight});

对比以上两种方法,显然css方法更省事,尤其在不用兼容ie6的现在。

希望本文所述对大家基于JS的web程序设计有所帮助。

相关文章

什么是深拷贝与浅拷贝?深拷贝与浅拷贝是js中处理对象或数据...
前言 今天复习了一些前端算法题,写到一两道比较有意思的题:...
最近在看回JavaScript的面试题,this 指向问题是入坑前端必须...
js如何实现弹出form提交表单?(图文+视频)
js怎么获取复选框选中的值
js如何实现倒计时跳转页面