JS當前頁面登入註冊框,固定DIV,底層陰影的執行個體代碼,登入註冊div

來源:互聯網
上載者:User

JS當前頁面登入註冊框,固定DIV,底層陰影的執行個體代碼,登入註冊div

這是一個執行個體,儲存代碼為html檔案運行試試吧。相容Firefox、ie6、ie7、ie8、Chrome等。

<!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=gb2312" /><title>JS當前頁面登入註冊框,固定DIV,底層陰影——幫客之家</title><!--一個按鈕點擊之後 顯示一個divdiv要水平 垂直置中當我瀏覽器高度 寬度變化的時候div依然水平 垂直置中點擊遮罩層,浮動層隱藏知識點:1.如何用css控制div水平垂直置中2.如何用js取得瀏覽器高度寬度3.如何控制resize事件--><style type="text/css">.hidden{ display:none}/*評論浮動層*/#smallLay{width:498px; height:100px;padding:4px 10px 10px;background-color:#FFFFFF;border:1px solid #05549d;color:#333333;line-height:24px;text-align:left;-webkit-box-shadow:5px 2px 6px #000;-moz-box-shadow:3px 3px 6px #555;}</style></head><script type="text/javascript">  //判斷瀏覽器ie6建立的div的樣式和非ie6建立的div的樣式  //建立div  function showid(idname) {    var isIE = (document.all) ? true : false;    var isIE6 = isIE && ([/MSIE (\d)\.0/i.exec(navigator.userAgent)][0][1] == 6);    var newbox = document.getElementById(idname);    newbox.style.zIndex = "9999";    newbox.style.display = "block"    newbox.style.position = !isIE6 ? "fixed" : "absolute";    newbox.style.top = newbox.style.left = "50%";    newbox.style.marginTop = -newbox.offsetHeight / 2 + "px";    newbox.style.marginLeft = -newbox.offsetWidth / 2 + "px";    var jihualayer = document.createElement("div");    jihualayer.id = "jihualayer";    jihualayer.style.width = jihualayer.style.height = "100%";    jihualayer.style.position = !isIE6 ? "fixed" : "absolute";    jihualayer.style.top = jihualayer.style.left = 0;    jihualayer.style.backgroundColor = "#000";    jihualayer.style.zIndex = "9998";    jihualayer.style.opacity = "0.6";    document.body.appendChild(jihualayer);    var sel = document.getElementsByTagName("select");    for (var i = 0; i < sel.length; i++) {      sel[i].style.visibility = "hidden";    }    function jihualayer_iestyle() {      jihualayer.style.width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth)+ "px";      jihualayer.style.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) +"px";    }    function newbox_iestyle() {      newbox.style.marginTop = document.documentElement.scrollTop - newbox.offsetHeight / 2 + "px";      newbox.style.marginLeft = document.documentElement.scrollLeft - newbox.offsetWidth / 2 + "px";    }    if (isIE) { jihualayer.style.filter = "alpha(opacity=60)"; }    if (isIE6) {      jihualayer_iestyle()      newbox_iestyle();      window.attachEvent("onscroll", function () {        newbox_iestyle();      })      window.attachEvent("onresize", jihualayer_iestyle)    }    jihualayer.onclick = function () {      newbox.style.display = "none"; jihualayer.style.display = "none"; for (var i = 0; i < sel.length; i++) {        sel[i].style.visibility = "visible";      }     }  }</script><body><div style="width:200px; height:100px;"></div><input name="" type="button" id="showbtn" value="點擊顯示" onclick="showid('smallLay')" /><!--收藏浮層開始--><div id="smallLay" style="display:none" >這<a href="http://jihua.cnblogs.com" style="text-decoration:none; color:Gray;">是</a>懸浮層</div><!--收藏浮層結束--><div id="a" style="height:1000px;">這<a href="http://jihua.cnblogs.com" style="text-decoration:none; color:Black;">是</a>普通層</div></body></html>

以上就是小編為大家帶來的JS當前頁面登入註冊框,固定DIV,底層陰影的執行個體代碼的全部內容了,希望對大家有所協助,多多支援幫客之家~

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.