国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 語(yǔ)言 > JavaScript > 正文

js與css實(shí)現(xiàn)彈出層覆蓋整個(gè)頁(yè)面的方法

2024-05-06 16:11:57
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
這篇文章主要介紹了js與css實(shí)現(xiàn)彈出層覆蓋整個(gè)頁(yè)面的方法,分別以實(shí)例形式展示了彈出層覆蓋整個(gè)頁(yè)面的css樣式與js控制的實(shí)現(xiàn)技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下
 
 

本文實(shí)例講述了js與css實(shí)現(xiàn)彈出層覆蓋整個(gè)頁(yè)面的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

彈出層透明背景加框的常用樣式和結(jié)構(gòu)如下:

復(fù)制代碼代碼如下:
.alertMessageBg{
position:fixed;
_position:absolute;
width:100%;
height:100%;
left:0;
top:0;
background:#000;
opacity:0.5;
-moz-opacity:0.5;
filter:alpha(opacity=50);
z-index:97;
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;
}

 

<div class="alertMessageBg"></div>
<div class="alertMessageDivBorder"></div>
<div class="alertMessageDiv"></div>

 

彈出層背景覆蓋整個(gè)網(wǎng)頁(yè)的方法

1.css方法

復(fù)制代碼代碼如下:
.alertMessageBg{
position:fixed;
_position:absolute;
width:100%;
height:100%;
left:0;
top:0;
background:#000;
opacity:0.5;
-moz-opacity:0.5;
filter:alpha(opacity=50);
z-index:97;
display:none;
}

 

2.js方法

復(fù)制代碼代碼如下:
.alertMessageBg{
position:absolute;
width:100%;
height:100%;
left:0;
top:0;
background:#000;
opacity:0.5;
-moz-opacity:0.5;
filter:alpha(opacity=50);
z-index:97;
display:none;
}

 

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

 

對(duì)比以上兩種方法,顯然css方法更省事,尤其在不用兼容ie6的現(xiàn)在。

希望本文所述對(duì)大家基于JS的web程序設(shè)計(jì)有所幫助。


發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 房产| 宽城| 通州市| 奈曼旗| 洪雅县| 筠连县| 怀宁县| 金湖县| 镇原县| 鄯善县| 苍溪县| 新密市| 揭东县| 大港区| 团风县| 金湖县| 合江县| 蓝田县| 前郭尔| 泗水县| 开江县| 简阳市| 柳州市| 蒙山县| 石渠县| 洪湖市| 孟州市| 株洲市| 镇江市| 青龙| 隆安县| 农安县| 吴桥县| 轮台县| 西充县| 武夷山市| 迁西县| 福建省| 遂溪县| 皋兰县| 文安县|