目前推荐使用哪种跨浏览器不透明度的css属性?

Cas*_*ert 0 css opacity

我想知道现在建议在css中使用不透明度的一天,这将适用于大多数broswers和版本.

应该只是opacity和/ filter或我应该使用'-ms-filter'吗?

谢谢.

4dg*_*rav 5

.transparent {
/* Required for IE 5, 6, 7 */
/* ...or something to trigger hasLayout, like zoom: 1; */
width: 100%; 

/* Theoretically for IE 8 & 9 (more valid) */   
/* ...but not required as filter works too */
/* should come BEFORE filter */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";

/* This works in IE 8 & 9 too */
/* ... but also 5, 6, 7 */
filter: alpha(opacity=50);

/* Older than Firefox 0.9 */
-moz-opacity:0.5;

/* Safari 1.x (pre WebKit!) */
-khtml-opacity: 0.5;

/* Modern!
/* Firefox 0.9+, Safari 2?, Chrome any?
/* Opera 9+, IE 9+ */
opacity: 0.5;
  }
Run Code Online (Sandbox Code Playgroud)

对于今天的使用.

.transparent {
zoom: 1;
filter: alpha(opacity=50);
opacity: 0.5;
}
Run Code Online (Sandbox Code Playgroud)

资源