展会信息港展会大全

css 实现浏览器窗口居中div层方法
来源:互联网   发布日期:2016-03-25 16:29:49   浏览:1152次  

导读:当然这个方法在IE6下面不能让灰色背景遮住表单元素(有办法解决用iframe,这里先不说了,因为IE6活不了多久了。)代码如下复制代码 <!DOCTYPE htm...

当然这个方法在IE6下面不能让灰色背景遮住表单元素(有办法解决用iframe,这里先不说了,因为IE6活不了多久了。)

代码如下

复制代码

<!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>

#overlay {

position:absolute;

top:0;

left:0;

width:100%;

height:100%;

background:#000;

opacity:0.5;

filter:alpha(opacity=50);

}

#win {

position:absolute;

top:50%;

left:50%;

width:400px;

height:200px;

background:#fff;

margin:-102px 0 0 -202px;

line-height: 200px;

text-align: center;

border: 4px solid #CCC;

}

</style>

<script>

</script>

</head>

<body>

<div id="overlay"></div>

<div id="win">层居中:)</div>

</body>

</html>

赞助本站

人工智能实验室

相关热词: 开发 编程 android

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港