一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

實現(xiàn)lightBox時的樣式與行為分離減少JS第1/2頁

[參與測試的瀏覽器:IE6 / IE7 / IE8 / FF3.5 / OP9.6 / SF4 / Chrome2 ]
[操作系統(tǒng):Windows]
本教程旨在實現(xiàn)lightBox時的樣式與行為分離,減少JS在各方面(全屏遮蔽、ie6中遮蔽select、雙向居中、高度自適應(yīng)內(nèi)容等)的工作。
先上代碼:
復(fù)制代碼 代碼如下:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="Chomo" />
<link rel="start" title="Home" />
<title>全屏屏蔽、自動居中的lightBox</title>
<style type="text/css">
* { margin:0; padding:0; }
html,body { height:100%; overflow:hidden; font:12px/1.5 simsun;}
.myPage { line-height:3; overflow:auto; width:100%; height:100%;}
.lightBox,
.popupCover,
.popupIframe,
.popupComponent { position:absolute; left:0; top:0; width:100%; height:100%;}
.popupComponent { z-index:2; display:none;}
.popupIframe { display:none; _display:block; _filter:alpha(opacity=0);}
.popupCover { background:#000; opacity:0.7; *filter:alpha(opacity=70);}
.lightBox { text-align:center; overflow:auto;}
.lightBoxContent { display:inline-block; *display:inline; zoom:1; width:300px; padding:10px; background:#fff; border:5px solid #00b4ff; vertical-align:middle;}
.lightBoxMaxHeight { display:inline-block; vertical-align:middle; height:100%; *height:99.5%; width:1px; overflow:hidden; margin-left:-1px;}
.lightBoxWrapper { display:inline-block; *display:inline; zoom:1; text-align:left;}
.lightBoxClose { color:#f00;}
.lightBoxSubmit { margin-top:10px; padding-top:5px; border-top:1px solid #ccc;}
.lightBoxSubmit input { font-size:12px; padding:0 10px; overflow:visible; margin:0 5px;}
</style>
</head>
<body>
<div class="popupComponent" id="lightBox">
<iframe class="popupIframe"></iframe>
<div class="popupCover"></div>
<div class="lightBox">
<span class="lightBoxMaxHeight"></span>
<div class="lightBoxContent">
<div class="lightBoxWrapper">
當提示小于一行時文字居中[br]
</div>
<div class="lightBoxSubmit">
<input type="button" value="確定" onclick="hideLayer('lightBox')" />
<input type="button" value="取消" onclick="hideLayer('lightBox')" />
</div>
</div>
</div>
</div>
<div class="popupComponent" id="lightBox2">
<iframe class="popupIframe"></iframe>
<div class="popupCover"></div>
<div class="lightBox">
<div class="lightBoxContent">
<div class="lightBoxWrapper">
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度 當內(nèi)容已經(jīng)超過了一屏的高度[br]
</div>
<div class="lightBoxSubmit">
<input type="button" value="確定" onclick="hideLayer('lightBox2')" />
<input type="button" value="取消" onclick="hideLayer('lightBox2')" />
</div>
</div>
<span class="lightBoxMaxHeight"></span>
</div>
</div>
<div class="myPage">
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
<div style="text-align:center;"><input type="button" value="位于第一屏的按鈕" onclick="showLayer('lightBox')" /></div>
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
<select><option>一個用于測試IE6中是否能覆蓋住的select</option></select>[br]
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
<select><option>又一個用于測試IE6中是否能覆蓋住的select</option></select>[br]
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
<div style="text-align:center;"><input type="button" value="位于第二屏中的按鈕" onclick="showLayer('lightBox')" /><input type="button" value="當內(nèi)容已經(jīng)超過了一屏的高度" onclick="showLayer('lightBox2')" /></div>
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
</div>
<script>
function showLayer(id) {
document.getElementById(id).style.display = "block";
}
function hideLayer(id) {
document.getElementById(id).style.display = "none";
}
</script>
</body>
</html>

這個lightBox具備以下特性,大家可以通過修改代碼測一測 ^-^:

在頁面中任意一位置點開,均能完美遮屏(此時無法直接控制包括滾動條在內(nèi)的任意元素),IE6中無須隱藏即能遮蔽select元素(iframe遮蔽法的缺陷:遮蔽后,如果拖動滾動條,select仍會移至頂層)。
lightBox的高度自適應(yīng)其內(nèi)容,并呈現(xiàn)完美的居中狀態(tài)。
內(nèi)容為單行時,居中顯示;內(nèi)容為多行時,居左顯示;內(nèi)容高度使lightBox超過屏高時呈現(xiàn)滾動條,并居頂顯示,讀者能完整閱讀。
如有興趣,構(gòu)成這個lightBox的以下小技巧可供您參詳:

1. 全屏遮蔽的方法:

A. 隱藏html/body的滾動條。
B. 用一個div做遮罩,再用一個div做帶有滾動條的頁面,一個疊上面,一個疊下面。
復(fù)制代碼 代碼如下:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="Chomo" />
<link rel="start" title="Home" />
<title>全屏遮蔽的方法</title>
<style type="text/css">
* {
margin:0; padding:0; /*--- 簡單的css reset,據(jù)說它的效率不高,請自行替換為高效的 ---*/
}
html,body {
height:100%; /*--- 有了這個高度,IE6下,body的子對象設(shè)置height:100%才有效 ---*/
overflow:hidden; /*--- 滅掉html或body產(chǎn)生的滾動條 ---*/
}
.page {
line-height:3;
overflow:auto; /*--- 滾動條就靠它了 ---*/
width:600px; height:400px; background:#f60; /*--- 暫時先做這么大,方便大家看清楚 ---*/
position:relative; left:50px; top:50px; /*--- 移動一點點,方便大家看清楚,把它去掉,遮罩的基本的效果就實現(xiàn)了 ---*/
}
.cover {
position:absolute;
width:600px; height:400px; background:#000;
opacity:0.7; *filter:alpha(opacity=70);
z-index:2;
}
</style>
</head>
<body>
<div class="cover"></div>
<div class="page">
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]假裝很豐富的內(nèi)容[br]
</div>
</body>
</html>

JavaScript技術(shù)實現(xiàn)lightBox時的樣式與行為分離減少JS第1/2頁,轉(zhuǎn)載需保留來源!

鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯(lián)系我們修改或刪除,多謝。

主站蜘蛛池模板: 久久精品国产999久久久 | 国产一区二区三区久久精品 | 美女被男人桶免费网站 | 亚洲精品国产综合一线久久 | 69视频在线观看免费 | 精品国产乱码久久久久久浪潮 | 欧美三级网站 | 黄色片视频网站 | 美女性色 | www.色中色| 性福利视频 | 国产自线一二三四2021 | 婷婷狠狠 | 国产精品久久久久久久久久一区 | 18女人腿打开无遮掩免费 | 国产精品自产拍在线观看 | 多人伦交性欧美在线观看 | 美女视频啪啪 | 国产精品亚欧美一区二区三区 | 日韩一区二区在线免费观看 | 69国产成人综合久久精品 | 日韩精品视频免费网址 | 免费精品美女久久久久久久久 | 久久久久久久久久免观看 | 四虎影视在线永久免费观看 | www.色综合.com| 婷婷玖玖 | 国产一区二区不卡视频 | 国产精品美女免费视频观看 | 高清激情小视频在线观看 | 久久男人视频 | 91碰视频 | 亚洲首页国产精品丝袜 | 亚洲人成人毛片无遮挡 | 哟哟色| 久久久久久久综合狠狠综合 | 中国女人一级做受免费视频 | 一区二区不卡在线观看 | 911露脸国语对白 | 99pao在线视频成精品 | 成年ssswww网站 |