今天在做网页的时候发现一个问题,在父标签中使用了overflow:hidden;时,如果子标签中有元素的position设置成relative的时候,在IE6和IE7中父元素的overflow对其将不起作用,在IE8、FF,Chrome中均正常显示如下代码:

<div style="height:100px; width:100px; background:#CCC; overflow:hidden;">
<div style="height:300px; width:90px; background:#999; position:relative;"></div>
</div>

效果如下图:

css中position:relative和overflow:hidden的问题

解决方案:将父标签的position也设置成relative,代码如下:

<div style="height:100px; width:100px; background:#CCC; overflow:hidden; position:relative;">
<div style="height:300px; width:90px; background:#999; position:relative;"></div>
</div>

效果如图所示:

css中position:relative和overflow:hidden的问题

效果如上图正常显示。

相关文章:

  • 2022-01-21
  • 2022-12-23
  • 2021-05-02
  • 2021-10-18
  • 2021-08-18
  • 2022-12-23
  • 2021-06-11
猜你喜欢
  • 2021-11-22
  • 2022-01-26
  • 2021-05-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案