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

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

 

你可能感兴趣的:(position)