zl程序教程

您现在的位置是:首页 >  其它

当前栏目

IE6下position解决父元素被撑开的问题

解决 元素 position IE6 问题
2023-09-14 09:01:07 时间

在IE6下面当子元素的宽度/高度大于父元素时, 父元素的宽度/高度就被撑开.IE7以上是不会被撑开的

<style>
.f{width:100px; height:100px; background:#808080}
.s{width:50px; height:150px; background:#4cff00;}
</style>
<div class="f">
    <div class="s"></div>
</div>

为了使IE6和其他的浏览器行为一致,我们可以在子元素中添加postion来解决问题

<style>
.f{width:100px; height:100px; background:#808080; _overflow:hidden;}
.s{width:50px; height:150px; background:#4cff00;_position: relative;}
</style>
<div class="f">
    <div class="s"></div>
</div>