js当前页面登录注册框,固定div,底层阴影的实例代码
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了js当前页面登录注册框,固定div,底层阴影的实例代码,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3457字,纯文字阅读大概需要5分钟。
内容图文
这是一个实例,保存代码为html文件运行试试吧。兼容火狐、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> <!-- 一个按钮 点击之后 显示一个div div要水平 垂直居中 当我浏览器高度 宽度变化的时候 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,底层阴影的实例代码全部内容了,希望大家多多支持脚本之家~
内容总结
以上是互联网集市为您收集整理的js当前页面登录注册框,固定div,底层阴影的实例代码全部内容,希望文章能够帮你解决js当前页面登录注册框,固定div,底层阴影的实例代码所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。