设置html元素的透明度
2010-11-18 08:58
89 查看
w3c标准属性是opacity,firefox支持,但IE却不支持该属性。
在FF3.5++,safari4,opera10,chrome4中测试都支持opacity。如设置div的透明度为40%:
注意:firefox3.5以下版本使用
IE下复杂些:
1、IE4-IE7使用filter: alpha(opacity=xx),但要同时使该元素拥有hasLayout
2、IE8下也可以用上面的filter: alpha(opacity=10),且不用设置zoom使元素拥有layout。同时IE8可以使用-ms-filter属性。如
详见:https://developer.mozilla.org/En/CSS:-moz-opacity
PS : IE9 beta已经支持opacity属性(2010-7-14)
在FF3.5++,safari4,opera10,chrome4中测试都支持opacity。如设置div的透明度为40%:
<!DOCTYPE HTML"> <html> <head> <title>set div opacity</title> <mce:style><!-- .wrapper { border:solid 1px gray; opacity:0.4; } --></mce:style><style mce_bogus="1"> .wrapper { border:solid 1px gray; opacity:0.4; } </style> </head> <body> <div class="wrapper"> set div opacity </div> </body> </html>
注意:firefox3.5以下版本使用
-moz-opacity属性。
IE下复杂些:
1、IE4-IE7使用filter: alpha(opacity=xx),但要同时使该元素拥有hasLayout
<!DOCTYPE HTML"> <html> <head> <title>set div opacity</title> <mce:style><!-- .wrapper { border:solid 1px gray; background-color:green; filter: alpha(opacity=10); zoom:1;/* set "zoom", "width" or "height" to trigger "hasLayout" in IE 7 and lower */ } --></mce:style><style mce_bogus="1"> .wrapper { border:solid 1px gray; background-color:green; filter: alpha(opacity=10); zoom:1;/* set "zoom", "width" or "height" to trigger "hasLayout" in IE 7 and lower */ } </style> </head> <body> <div class="wrapper"> set div opacity </div> </body> </html>
2、IE8下也可以用上面的filter: alpha(opacity=10),且不用设置zoom使元素拥有layout。同时IE8可以使用-ms-filter属性。如
-ms-filter: "alpha(opacity=10)"; /* IE 8 */
详见:https://developer.mozilla.org/En/CSS:-moz-opacity
PS : IE9 beta已经支持opacity属性(2010-7-14)
相关文章推荐
- 设置HTML元素的透明度
- 使用Javascript设置HTML元素的不透明度
- Android Dialog 空白区域设置透明度
- android AlertDialog透明度的设置
- Web前端html中通过CSS来设置div背景颜色透明度
- iOS 设置父控件的透明度后,子控件会受到父控件透明的影响。
- 透明度设置
- 设置背景图片透明度
- WPF设置控件的透明度、背景色 分类: .NET 2012-05-28 14:55 6035人阅读 评论(0) 收藏
- setAlpha方法 设置透明度
- 设置透明度的背景
- C#-窗体透明度,通过TrackBar设置窗体透明度动态效果---ShinePans
- Flex中如何通过设置backgroundAlpha风格来设定VideoDisplay控件的背景透明度(background alpha)的例子
- 01-diiv透明度设置
- Android 设置透明度遇到的坑
- CSS中透明度的设置(兼容多种浏览器)
- 使用css3背景渐变中的透明度来设置不同颜色的背景渐变
- Android 设置屏幕背景透明度
- css透明度设置兼容所有浏览器
- 设置NumericStepper控件的背景色和透明度。