首先看看A级浏览器所支持的用CSS实现元素透明的方案:
浏览器 | 最低 版本 | 方案 |
---|---|---|
Internet Explorer | 4.0 | filter: alpha(opacity=xx); |
5.5 | filter: progid:DXImageTransform.Microsoft.Alpha(opacity=xx); | |
8.0 | filter: "alpha(opacity=xx)"; | |
Firefox (Gecko) | 0.9 (1.7) | opacity |
Opera | 9.0 | opacity |
Safari (WebKit) | 1.2 (125) | opacity |
实际上在IE8中,-ms-filter是filter的别名,两者区别是-ms- filter的属相值必须被单引号或双引号包围,而filter中则不是必须,而在IE8之前的版本中,filter的属性值必须不被单引号或双引号包围。
IE中的HTML元素要实现透明,则其必须具备layout,这样的元素有仅可读的属性hasLayout,且其值为true。具体情况如下:
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就不行。 元素在怪癖模式(compat mode)下。 新闻热点
疑难解答