您的位置:首页 > 其它

IE6下与float元素相邻的position:absolute元素消失BUG

2011-01-26 18:00 573 查看
代码

<!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>IE6下与float元素相邻的position:absolute元素消失BUG</title>
<style type="text/css">
*{ margin:0; padding:0}
.wrap{ width:800px; height:200px; margin:0 auto; position:relative}
.left{ width:300px; height:200px; background-color:#F00; float:left}
.right{ width:500px; height:200px; background-color:#00F; float:left}
.pos{ width:600px; height:30px; background-color:#000; color:#fff; position:absolute; left:0; top:0;}
.pos2{ top:60px;}
</style>
</head>

<body>
<div class="wrap">
<div class="pos">如果不加下面的div,在IE6下是看不见我的</div>
<!--[if IE 6]><div></div><![endif]-->
<div class="left"></div>
<div class="right"></div>
<!--[if IE 6]><div></div><![endif]-->
<div class="pos pos2">如果不加上面的div,在IE6下是看不见我的,总之是要与浮动之间加个空的DIV</div>
</div>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: