使用例子:
div {background: rgba(200, 54, 54, 0.5);}
关于颜色请参考:http://www.w3.org/TR/2003/CR-css3-color-20030514/#rgba-color
使用RGB:
<div style="background: rgb(0, 0, 128); height: 100px; width: 100px;"></div>
使用RGBA:
<div style="height: 333px; width: 500px;position: relative;"> <img src="http://farm4.static.flickr.com/3223/3290904238_cd8e54d044.jpg" width="500" height="333" /> <div style="position: absolute; height: 313px; top: 10px; left: 10px; width: 480px; background: rgb(51, 102, 0); background: rgba(51, 102, 0, 0.5);">RGBa 浏览器支持</div> </div>
RGBa 浏览器支持
rgba(0, 0, 128, 0.5)
是指颜色为rgb(0, 0, 128)
同等#000080
,0.5
是opacity
的值
IE可以使用:filter:alpha(opacity=50);
firefox使用:opacity: 0.5;
看:CSS Transparency Settings for All Browsers
Browser, Version, Platform | Outcome | Fallback |
---|---|---|
Firefox 3.0.5 (OS X) | Works | -- |
Firefox 3.0.5 (Windows XP, Vista) | Works | -- |
Firefox 2.0.0.18 (PC) | Doesn't Work | Solid Color |
Safari 4 (Developer Preview, OS X) | Works | -- |
Safari 3.2.1 (OS X, Windows XP) | Works | -- |
Mobile Safari (iPhone) | Works | -- |
Opera 9.6.1 | Doesn't Work | Solid Color |
Opera 10 Beta (Linux & Windows) | Works | -- |
IE 4.01 | Doesn't Work | No Color |
IE 5.5 (PC via IETester) | Doesn't Work | No Color |
IE 6 (PC via IETester) | Doesn't Work | Solid Color |
IE 7 | Doesn't Work | Solid Color |
IE 8 beta 2 | Doesn't Work | Solid Color |
Google Chrome 0.4.154.33 (Windows XP) | Works | -- |
Google Chrome 1.0.154.46 (Windows XP) | Works | -- |
Netscape 4.8 (PC) | Doesn't Work | No Color |
Navigator 9.0.0.5 Linus | Doesn't Work | Solid Color |
SeaMonkey 1.1.14 | Doesn't Work | No Color |
SeaMonkey 2.0 | Works | -- |
Sunrise 1.7.5 | Works | -- |
Stainless 0.2.5 | Works | -- |
Flock 1.2.7 | Doesn't Work | Solid Color |
Flock 2.0.2 | Works | -- |
BlackBerry Storm Browser | Works | -- |
Camino 1.6.6 | Doesn't Work | Solid Color |
Camino 2.0b1 | Works | -- |
Iceape 1.1.14 (Linux) | Doesn't Work | Solid Color |
Kazehakase 0.5.2 (Linux) | Doesn't Work | Solid Color |
Avant 11.7 (Windows XP) | Doesn't Work | Solid Color |
没有评论:
发表评论