让DIV打开时候在居中位置
来源:互联网 发布:淘宝热度查询 编辑:程序博客网 时间:2024/06/05 19:40
以下代码直接进入html运行即可!无论你的网页拉到什么位置,显示出来的DIV都是在当前框架的最中间
<!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" /><title> 你的标题</title><style type="text/css">/*弹出层的STYLE*/.mydiv {background-color: #ff6;border: 1px solid #f90;text-align: center;line-height: 40px;font-size: 12px;font-weight: bold;z-index:99;width: 300px;height: 120px;left:50%;/*FF IE7*/top: 50%;/*FF IE7*/margin-left:-150px!important;/*FF IE7 该值为本身宽的一半 */margin-top:-60px!important;/*FF IE7 该值为本身高的一半*/margin-top:0px;position:fixed!important;/*FF IE7*/position:absolute;/*IE6*/_top: expression(eval(document.compatMode && document.compatMode=='CSS1Compat') ? documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 :/*IE6*/ document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2);/*IE5 IE5.5*/}.bg {background-color: #ccc;width: 100%;height: 100%;left:0;top:0;/*FF IE7*/filter:alpha(opacity=50);/*IE透明度*/opacity:0.5;/*FF*/z-index:1;position:fixed!important;/*FF IE7*/position:absolute;/*IE6*/_top: expression(eval(document.compatMode && document.compatMode=='CSS1Compat') ? documentElement.scrollTop + (document.documentElement.clientHeight-this.offsetHeight)/2 :/*IE6*/ document.body.scrollTop + (document.body.clientHeight - this.clientHeight)/2);/*IE5 IE5.5*/}/*The END*/</style><script type="text/javascript">function showDiv(){document.getElementById('popDiv').style.display='block';document.getElementById('bg').style.display='block';}function closeDiv(){document.getElementById('popDiv').style.display='none';document.getElementById('bg').style.display='none';}</script></head><body><div id="popDiv" class="mydiv" style="display:none;">GOOD<br/>GOOD<br/><a href="javascript:closeDiv()">close</a></div><div id="bg" class="bg" style="display:none;"></div><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><div style="padding-top: 20px;"><input type="Submit" name="" value="Show Div" onclick="javascript:showDiv()" /></div></body></html>
- 让DIV打开时候在居中位置
- 让div在body中居中对齐
- 如何让DIV在body中居中
- 让div在页面居中的方法
- 让DIV在屏幕上居中
- 让div在浏览器可视范围居中
- 让一个div在页面底下,居中
- 如何让img在div中居中
- 使用属性position:fixed的时候如何才能让div居中
- 如何让图片在div里左右居中,上下居中
- DIV位置永恒居中
- DIV设置位置居中
- 如何让子div在父div中水平居中?
- 让多个子div在父div中水平居中
- 嵌套盒子,让子div在父div中居中
- 让div或img在div中垂直居中
- 让div居中对齐
- 让div居中对齐
- MPC8314 (e300核) uboot 调试 一
- GPS编码格式及C语言解码
- Redis实战系列(1) 运行多个实例以充分发挥多核处理器的能力
- sql 不同表格不同数据的前几行查询
- 详解MYSQL数据库密码的加密方式及破解方法(1)
- 让DIV打开时候在居中位置
- SAP 《MM学习指南》操作记录----库存盘点时库存的冻结
- [Linux driver] Mutex, semaphore, spinlock的深度解析
- webmin简介
- 在一个字符串中找到第一个只出现一次的字符
- poj 1067
- selen新窗口问题
- 使用DateGridView显示表所有信息
- Oracle 查看表空间使用率 SQL 脚本