您的位置:首页 > 其它

怪异模式下absolutely在IE6/7中的Bug

2009-11-06 00:54 351 查看
绝对定位的元素其偏移量是相对于 absolute或者relative元素的,如果父元素是static,则继续寻找父父的元素是否是absolute或者relative的,直到body为止
示例里面父元素是static的,所以应该是相对于body定位的...

<!---->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<mce:style><!--
*{
margin:0px;
padding:0px;
}
#d30{
height:100px;
}
#d01{
background:red;
width:500px;
height:500px;
overflow:hidden;
position:static;
}
#d01 #d02{
background:yellow;
width:200px;
height:200px;
position:absolute;
top:100px;
}

--></mce:style><style mce_bogus="1">		*{
margin:0px;
padding:0px;
}
#d30{
height:100px;
}
#d01{
background:red;
width:500px;
height:500px;
overflow:hidden;
position:static;
}
#d01 #d02{
background:yellow;
width:200px;
height:200px;
position:absolute;
top:100px;
}
</style>
</head>
<body>
<div id="d30"></div>
<div id="d01">
<div id="d02"></div>
</div>
</body>
</html>


可以看到d02的位置相对于父元素d01,而不是body,去掉d01的overflow:hidden;后正常,或者加dtd,在标准模式下也正常!

建议大家尽量加doctype,标准模式下css正常发挥作用。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: