遮罩效果|div弹出层|模式层
2011-03-28 23:16
459 查看
预知效果如何,查看源代码,预览效果:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title></title> <!-- 样式 --> <style type="text/css"> /* div的 position 为 absolute 就都取绝对定位,所有的div就会叠在一起 */ /* 页面加载的时候遮罩div 和 消息 div 不显示,点击显示后再显示 */ /* 由于用第二个div来挡住页面所以第二个div的宽度和高度都是100% */ #divMain { width:1024px; height:600px; margin:0 auto; padding:20px; background-color:#ccc; z-index:1;//设置div层所处的位置 position:absolute; } #divLayer { width:100%; height:100%; background-color:#eee; filter:alpha(opacity=30);/*设置半透明效果*/ opacity:0.3;/*透明度*/ z-index:2;/*设置div层所处的位置*/ position:absolute; display:none; cursor:not-allowed; } #divMsg { margin-top:10%; width:240px; height:100px; line-height:10px; text-align:center; margin-left:40%; position:absolute; display:none; background-color:white; border:2px solid yellow; z-index:3;/*设置div层所处的位置*/ } .btn { border:4px solid yellow; font-family:微软雅黑; font-size:12px; } </style> <!-- 控制脚本 --> <script language="javascript"> function showMsg(){ /* 得到遮罩div && 消息div */ var _divLayer=document.getElementById("divLayer"); var _divMsg=document.getElementById("divMsg"); _divLayer.style.display="block"; _divMsg.style.display="block"; } function logout(){ var _divLayer=document.getElementById("divLayer"); var _divMsg=document.getElementById("divMsg"); _divLayer.style.display="none"; _divMsg.style.display="none"; alert("login successfull!"); } </script> </head> <body> <!-- 遮罩用的div --> <div id="divLayer"> </div> <!-- 消息div --> <div id="divMsg"> <div style="margin-top:7px;">username:<input type="text" id="userName" maxLength="16"/></div> <div style="margin-top:6px;">userpass:<input type="password" id="userPass" maxLength="16"/></div> <div style="margin-top:8px;"> <input type="button" value="login" onclick="logout();"/> <input type="button" value="exit" onclick="logout();"/> </div> </div> <!-- 正常的div --> <div id="divMain"> <input type="button" value=" 登 录 " id="btnLogin" class="btn" onclick="showMsg();"/> </div> </body> </html>
相关文章推荐
- js遮罩层弹出div效果实现
- js弹出层、遮罩、div层的几种效果
- html 锁定页面(js遮罩层弹出div效果)
- JS弹出可移动的DIV对话框透明遮罩效果
- html 锁定页面(js遮罩层弹出div效果)
- JS+CSS实现鼠标经过弹出一个DIV框完整实例(带缓冲动画渐变效果)
- 用Div仿showModalDialog模式菜单的效果的代码
- 一个不错的可拖动层遮罩加ALPHA滤镜(点击弹出后背景变浅色,信息提示框效果)
- (简单的弹出div 覆盖背景)改善用户体验之alert提示效果 http://www.blueidea.com/tech/web/2006/4185.asp
- 用CSS实现的模式窗口效果,弹出固定大小的窗口
- [转]创建一个JavaScript弹出DIV窗口层的效果
- 使用jQuery实现DIV弹出效果
- 半透明遮罩效果 DIV
- 简单js遮罩效果,弹出注册界面
- Dialog弹出后显示遮罩效果
- 纯CSS打造的DIV弹出层效果
- 有关div页面拖动、缩放、关闭、遮罩效果代码
- 可以拖动的居中弹出层带遮罩效果
- jsp页面的div层的弹出效果
- jQuery实现单击按钮遮罩弹出对话框效果(2)