1 .opacity{ 2 position: absolute; 3 top: 0px;left: 0px; 4 background: #000; 5 filter:alpha(opacity=50); /* IE */ 6 -moz-opacity:0.5; /* 老版Mozilla */ 7 -khtml-opacity:0.5; /* 老版Safari */ 8 opacity: 0.5; /* 支持opacity的浏览器*/ 9 }
Js写法
1 object.filter = "alpha(opacity=" + opacity + ")"; /* IE */ 2 object.MozOpacity = (opacity / 100); /* 老版Mozilla */ 3 object.KhtmlOpacity = (opacity / 100); /* 老版Safari */ 4 object.opacity = (opacity / 100); /* 支持opacity的浏览器*/
原文:http://www.cnblogs.com/ahwu/p/3699226.html