IE中hasLayout属性布局问题

IE中 Internet Explorer for Windows的私有概念,有很多奇怪的渲染问题可以通过赋予其”layout”得到解决。John Gallant 和 Holly Bergevin 把这些问题归类为”尺寸臭虫(dimensional bugs)”,意思是这些臭虫可以通过赋予相应元素某个宽度或高度解决。

元素是否具有”layout”可能会引发如下的一些问题:

* IE 很多常见的浮动臭虫。
* 元素本身对一些基本属性的异常处理问题。
* 容器和其子孙之间的空白边重叠问题。
* 使用列表时遇到的诸多问题。
* 背景图像的定位偏差问题。
* 使用脚本时遇到的浏览器之间处理不一致的问题。


下列元素应该是默认具有 layout 的:
* <html>, <body>
* <table>, <tr>, <th>, <td>
* <img>
* <hr>
* <input>, <button>, <select>, <textarea>, <fieldset>, <legend>
* <iframe>, <embed>, <object>, <applet>
* <marquee>


下列 CSS 属性和取值将会让元素获得 layout:
    * position: absolute
      绝对定位元素的包含区块(containing block)就会经常在这一方面出问题。
    * float: left|right
      由于 layout 元素的特性,浮动模型会有很多怪异的表现。
    * display: inline-block
      当一个内联级别的元素需要 layout 的时候往往就要用到它,这也可能也是这个 CSS 属性的唯一效果–让某个元素拥有 layout。”inline-block行为”在IE中是可以实现的,但是非常与众不同: IE/Win: inline-block and hasLayout 。
    * width: 除 “auto” 外的任意值
      很多人遇到 layout 相关问题发生时,一般都会先尝试用这个来修复。
    * height: 除 “auto” 外的任意值
      height: 1% 就在 Holly Hack 中用到。
    * zoom: 除 “normal” 外的任意值
      IE专有属性。不过 zoom: 1 可以临时用做调试。
    * writing-mode: tb-rl
      MS专有属性。
    * overflow: hidden|scroll|auto
      在 IE7 中,overflow 也变成了一个 layout 触发器,这个属性在之前版本 IE 中没有触发 layout 的功能。
    * overflow-x|-y: hidden|scroll|auto
      overflow-x 和 overflow-y 是 CSS3 盒模型中的属性,尚未得到浏览器的广泛支持。他们在之前版本IE中没有触发 layout 的功能。
    * 另外 IE7 的荧幕上又新添了几个 haslayout 的演员,如果只从 hasLayout 这个方面考虑,min/max 和 width/height 的表现类似,position 的 fixed 和 absolute 也是一模一样。
    * position: fixed
    * min-width: 任意值
      就算设为0也可以让该元素获得 layout。
    * max-width: 除 “none” 之外的任意值
    * min-height: 任意值
      即使设为0也可以让该元素的 haslayout=true
    * max-height: 除 “none” 之外的任意值


参考:

http://adamghost.com/2009/03/ie-has-layout-and-bugs-zh/
http://adamghost.com/2008/12/ie-haslayout-%E8%AF%A6%E8%A7%A3/
http://www.cnblogs.com/rubylouvre/archive/2010/12/11/1900826.html

你可能感兴趣的:(windows,css,浏览器,脚本,IE)