【hasLayout触发方式】和【hasLayout——IE中css bug的罪魁祸首】(转自:http://hi.baidu.com/oxid/blog/item/8481e6a28128b3a0caefd044.html 和 http://www.k6
来源:互联网 发布:济南上知教育怎么样 编辑:程序博客网 时间:2024/04/29 06:39
【hasLayout触发方式】 IE中的HTML元素要实现透明,则其必须具备layout,这样的元素有仅可读的属性hasLayout,且其值为true。具体情况如下: 关于hasLayout的更多详情可以看Exploring Internet Explorer “HasLayout” Overview和On having layout 什么是hasLayout? 要想更好的理解css,尤其是 IE 下对 css 的渲染,haslayout 是一个非常有必要彻底弄清楚的概念。大多IE下的显示错误,就是源于 haslayout。 什么情况下hasLayout不会出现? 一般情况都不会出现,当然除了下面罗列的默认具有hasLayout的元素和使用特定样式触发以外; hasLayout的触发条件: * position: absolute(IE5+) 清除或重置hasLayout: * position: static(IE5+) haslayout 问题的调试与解决 当网页在ff中表现正常,而在 IE7 或更早版本中有异常表现时,可以尝试激发 haslayout 来看看是不是问题所在。常用的方法是给某元素 css 设定zoom:1。使用 zoom:1 是因为大多数情况下,它能在不影响现有环境的条件下激发元素的 haslayout。而一旦问题消失,那基本上就可以判断是haslayout 的原因。然后就可以通过设定相应的 css 属性来对这个问题进行修正了。建议首先要考虑的是设定元素的width/height 属性,其次再考虑其他属性。body
、img
、table
、tr
、th
、td
等元素的hasLayout
一直为true
。type
为text
、button
、file
或select
的input
的hasLayout
一直为true
。{position:absolute}
的元素的hasLayout
为true
{float:left|right}
的元素的hasLayout
为true
{display:inline-block}
的元素的hasLayout
为true
{height:xx}
或{width:xx}
的元素必须具体以下两个条件之一,其hasLayout
才能为true
:display
的值是block
,如demo3就不行。{zoom:xx}
的元素在IE8的兼容模式或IE8之前的浏览器中其hasLayout
为true
,但在IE8的标准模式下则不会触发hasLayout
。{writing-mode:tb-rl}
的元素的hasLayout
为true
。contentEditable
的属性值为true
。{display:block}
的元素的hasLayout
一直为true
,如demo8。
http://striblog.com/?p=13
http://hi.baidu.com/lijing00333/blog/item/bbfdd21424f5535bf2de3267.html
haslayout 是Windows Internet Explorer渲染引擎的一个内部组成部分。在InternetExplorer中,一个元素要么自己对自身的内容进行计算大小和组织,要么依赖于父元素来计算尺寸和组织内容。为了调节这两个不同的概念,渲染引擎采用了 hasLayout 的属性,属性值可以为true或false。当一个元素的 hasLayout属性值为true时,我们说这个元素有一个布局(layout)。
通过 IE Developer Toolbar 可以查看 IE 下 HTML元素是否拥有haslayout,在 IE Developer Toolbar 下,拥有 haslayout的元素,通常显示为“haslayout = -1”。
它会带来各种诡异表现,当你发现IE7-出现了一些不可思议的问题,首先要检查的就是是否是hasLayout在捣鬼;
hasLayout只出现在IE7及更早版本中,IE8不存在hasLayout解析模式,我们只讨论指定doctype的情况。
* float: left|right(IE5+)
* display: inline-block(IE5+)
* width: “auto”以外的任何值(IE5+; 对inline元素无效)
* height: “auto”以外的任何值(IE5+; 对inline元素无效)
* zoom: “normal”以外的任何值(IE5.5+; IE私有属性)
* writing-mode: tb-rl(IE5+; IE私有属性)
* overflow: hidden|scroll|auto(IE7; 此属性在IE6及更早版本中不能应用在未触发hasLayout的元素上)
* overflow-x|-y: hidden|scroll|auto(IE7; 此属性在IE6及更早版本中不触发hasLayout; 此属性在CSS3中才获支持)
* min-width: 任何值(IE7; 即使是0)
* max-width: “none”以外的任何值(IE7)
* min-height: 任何值(IE7)
* max-height: “none”以外的任何值 (IE7)
* position: fixed(IE7)
* float: none(IE5+)
* display: “inline-block”以外的任何值(IE5+)
* width|height: “auto”(IE5+; 对inline元素无效)
* zoom: “normal”(IE5.5+; IE私有属性)
* writing-mode: 从’tb-rl’到’lr-tb’(IE5+; IE私有属性)
* max-width|max-height: “none”(IE7)
* overflow: visible(IE7)
对于IE7 ,最好的办法是设置最小高度属性为0;这个技术是无害的,因为0本来就是这个属性的初始值。而且没有必要对其他浏览器隐藏这个属性。
对 IE6 及更早版本来说,常用的方法被称为霍莉破解(Holly hack),即设定这个元素的高度为 1%(height:1%;)。需要注意的是,当这个元素的 overflow 属性被设置为 visible 时,这个方法就失效了。或者使用 IE的条件注释。
- 【hasLayout触发方式】和【hasLayout——IE中css bug的罪魁祸首】(转自:http://hi.baidu.com/oxid/blog/item/8481e6a28128b3a0caefd044.html 和 http://www.k6
- currentStyle IE和ff 获取外联样式(转自:http://hi.baidu.com/aganle/blog/item/86109bcf27d2b70b93457e41.html)
- currentStyle IE和ff 获取外联样式(转自:http://hi.baidu.com/aganle/blog/item/86109bcf27d2b70b93457e41.html)
- 显示html/css的警告错误或错误(转自:http://hi.baidu.com/86727515/blog/item/f030f0050fa8c1c77b89471d.html)
- 设备驱动中环形缓冲区数据存储和读写同步的实现[转自:http://hi.baidu.com/whandsome/blog/item/3834e32a9994692cd52af1f9.html]
- HTTPS和HTTP的区别(http://hi.baidu.com/kannan/blog/item/27ab730efbe744cb7bcbe1c4.html)
- ExtJS Grid tooltip的几种实现方式(转自http://hi.baidu.com/wangkai99/blog/item/eff4a162c7e86e750d33fa84.html)
- Hashtable和HashMap类的区别(转载自-http://hi.baidu.com/danghj/blog/item/635c862f15949c381f3089a4.html)
- cdecl、stdcall、fastcall、declspec 的用法和区别(转载自:http://hi.baidu.com/guqiwei/blog/item/6b56f413848394075aaf53f2.html)
- struts2的配置详解(转自 http://hi.baidu.com/louhu/blog/item/52d2d1652bbeccfaf6365458.html)
- 关于sqlite3的性能(转自:http://hi.baidu.com/snailzone/blog/item/da9368662bc94f25aa184c2b.html)
- 会说话的猪 转自:http://hi.baidu.com/gg81/blog/item/91c088ef5b177114fdfa3c72.html
- 认识hasLayout——IE浏览器css bug的一大罪恶根源(转载网址http://neverned.blog.163.com/blog/static/1265524200933021130561/)
- exits和In的区别(http://hi.baidu.com/delphi_relive/blog/item/d7c0034a49c4932208f7ef21.html)
- 一份详尽的IPC$资料 转载自:http://hi.baidu.com/h4ck3rsbr/blog/item/bf4282c328b73751b319a89b.html
- proteus 技巧(转自http://hi.baidu.com/strawxw/blog/item/fed0b6350684b61591ef3974.html)
- 创业须知[转自http://hi.baidu.com/rainstudy/blog/item/f5c48658c93e53dd9c8204a1.html]
- struts validate 动态平验证(转自http://hi.baidu.com/twobrushes/blog/item/ff088fdd66d484305982dda4.html)
- freeBSD下挂载u盘
- debian 6.0 安装 xen
- opencv winnt.h出错解决方案
- JAVA序列化基础知识Serializable与Externalizable的区别
- java 中int String类型转换
- 【hasLayout触发方式】和【hasLayout——IE中css bug的罪魁祸首】(转自:http://hi.baidu.com/oxid/blog/item/8481e6a28128b3a0caefd044.html 和 http://www.k6
- Android实战(2)_MID上真机调试
- 跟我一起学MiniOA:第一章 网页制作基础知识(连载)
- Linux系统启动过程
- cvCaptureFromCAM函数问题
- S3C2440驱动简析——串口驱动
- 安装网络文件系统时出错:mount error 20 = Not a directory
- Ubuntu10.04设置静态IP
- 微策略面试题---关于权重