Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 网站建设 > PHP > ie haslayout
【标  题】:ie haslayout
【关键字】:ie,haslayout
【来  源】:http://blog.csdn.net/rob123/archive/2007/01/11/1479827.aspx

ie haslayout

Your Ad Here

今天群里面的朋友问了一个问题:

<div style="background:#f00;filter:alpha(opacity=50);">111</div>

为什么设置的透明度失效.

其实这个问题是IE特有的haslayout属性引起的。只有当haslayout=true时IE的filter才会起作用。

下面是关于haslayout的介绍:

hasLayout 是IE特有的一个属性。微软 filter 滤镜要求 hasLayout=true 方可执行(否则没有效果)。这个属性可能导致问题的问题还有:

* Many common IE float bugs.
* Boxes themselves treating basic properties differently.
* Margin collapsing between a container and its descendants.
* Various problems with the construction of lists.
* Differences in the positioning of background images.
* Differences between browsers when using scripting.

下列元素默认 hasLayout=true

* <table>
* <td>
* <body>
* <img>
* <hr>
* <input>, <select>, <textarea>, <button>
* <iframe>, <embed>, <object>, <applet>
* <marquee>

下列属性也会导致 hasLayout=true

position: absolute
Refers to its containing block, and that's where some problems begin.

float: left|right
The float model has a lot of quirks due to some aspects of a layout element.

display: inline-block
Sometimes a cure when the element is at inline level and needs layout. Applying layout is probably the only real effect of this property. The “inline-block behaviour” itself can be achieved in IE, but quite independently: IE/Win: inline-block and hasLayout.

width: any value
This is often an implicit fix, more often the trigger when hasLayout does things wrong.

height: any value
height: 1% is used in the Holly Hack.

zoom: any value (MSDN)
MS proprietary, does not validate. zoom: 1 can be used for debugging.

writing-mode: tb-rl (MSDN)
MS proprietary, does not validate.

inline 元素的特殊情况

* width and height trigger hasLayout in IE 5.x and IE 6 in quirks mode only. As of IE6, when the browser is in “standards-compliance mode” inline elements will ignore the width and height properties, and setting the width and height properties will not cause the element to have layout.

ie5.x和 ie 6 quirk 模式中,设置了 width 或者 height 属性的元素 hasLayout=true。ie 6 standards-compliance mode(标准兼容模式)时,设置了 width 或者 height 属性的元素 hasLayout=false

* zoom always triggers hasLayout, but it's not supported in IE5.0.
zoom 会导致 hasLayout=true,但 ie 5 不支持该属性。

通过 x.currentStyle.hasLayout 来获得 hasLayout 值(注意IE only,其他浏览器无效)。



hasLayout 不可写。也就是说,你不能通过 hasLayout=true 来设置 hasLayout 属性,而只能通过 width,height,zoom 等改变 hasLayout 状态。

Another thing to consider is how “layout” affects scripting. The clientWidth/clientHeight properties always return zero for elements without “layout.” This can be confusing to new scripters and is different to how Mozilla browsers behave. We can use this fact to determine “layout” for IE5.0: If the clientWidth is zero then the element does not have layout.

hasLayout=false 元素返回的 clientWidth/clientHeight 属性总是0。比如下面的代码



大多数情况下,我们是需要 hasLayout=true 的,通过CSS设置 hasLayout=true 的hack方法有:

/* \*/
* html .gainlayout { height: 1%; }
/* */

或者

.gainlayout { _height: 0; }

或者

<!--[if lte IE 6]>
<style>
.gainlayout { height: 1px; }
</style>
<![endif]-->

或者针对最近发布的 IE 7 测试版

<!--[if lt IE 7]><style>
/* style for IE 6 + IE5.5 + IE5.0 */
.gainlayout { height: 0; }
</style><![endif]-->

<!--[if IE 7]><style>
.gainlayout { zoom: 1;}
/* or whatever we might need tomorrow */
</style><![endif]-->

注意这些方法都是有局限性的,具体请参照原文

ie使用 float 要小心,具体见 http://www.satzansatz.de/cssd/onhavinglayout.html#clear

相关资料:
On having layout
HasLayout Overview

 

网页鼠标抓词中英文单词对译的AJAX小例子(兼容版本):【上一篇】
showModalDialog和showModelessDialog:【下一篇】
【相关文章】
  • GridView无刷新手动分页
  • ASP.Net2.0 GridView 多列排序,显示排序图标,分页
  • 微软高管称已启动IE8浏览器研发 两年内出成品
  • 如何将gridview中的数据导出到Excel中
  • OpenSessionInView模式
  • 判断数组 fields中是否存在s
  • 在输出avi文件的时候,为什么在movie clip里面做的动画,
  • IE进程与资源管理器进程的合并对Appeon Web应用影响
  • 程序集清单定义与程序集引用不匹配-TreeView控件
  • 在DataGridView最下方通过paint显示一行相关数据
  • 【随机文章】
  • 如果hp机器Att灯闪应该怎么办?
  • 小小快捷方式克死Windows 98
  • flash中Alt键的妙用
  • 咨询入门教程之三--咨询顾问是怎样炼成的?
  • (5)'c++:COMPLETE REFERENCE' 第一部分 第一章(c语言概述) 第四节
  • Jan Goyvaerts正则表达式(一)
  • 致命的regexp文件
  • 数据库连接池实现[转载]
  • 呵呵 正式学习ACM一个月了 留个纪念吧~
  • FAMP2.0一键搭建Apache+mysql+php+GD库+phpmyadmin(for Fre
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.