>  기사  >  웹 프론트엔드  >  IE6下为什么overflow属性不起作用了_html/css_WEB-ITnose

IE6下为什么overflow属性不起作用了_html/css_WEB-ITnose

WBOY
WBOY원래의
2016-06-24 11:32:141351검색

IE6下为什么overflow属性不起作用了:
建议:尽可能的手写代码,可以有效的提高学习效率和深度。
在IE6浏览器下,如果一个对象的子对象是绝对定位或者相对定位,那么父对象的overflow属性则对子对象不起作用。
代码实例如下:

<!DOCTYPE html><html><head><meta charset=" utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style type="text/css">.parent {  width: 200px;  height: 200px;  border: 1px solid green;  overflow: hidden;}.children {  width: 300px;  height: 100px;  border: 1px solid blue;  position: relative;}</style></head><body>  <div class="parent">    <div class="children">大家好,欢迎来到蚂蚁部落,希望大家给予有意见的建议与意见!</div>  </div></body></html>

以上代码中的子div会溢出,父对象的overflow属性并没有生效。解决此bug的方法就是给父对象添加绝对定位或者相对定位。
代码如下:

<!DOCTYPE html><html><head><meta charset=" utf-8"><meta name="author" content="http://www.softwhy.com/" /><title>蚂蚁部落</title><style type="text/css">.parent {  width: 200px;  height: 200px;  border: 1px solid green;  overflow: hidden;  position: relative;}.children {  width: 300px;  height: 100px;  border: 1px solid blue;  position: relative;}</style></head><body>  <div class="parent">    <div class="children">大家好,欢迎来到蚂蚁部落,希望大家给予有意见的建议与意见!</div>  </div></body></html>

原文地址:http://www.softwhy.com/forum.php?mod=viewthread&tid=3385

更多内容可以参阅:http://www.softwhy.com/divcss/

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.