我正在使用这个CSS作为<div>
的背景不透明度。
background: rgba(255, 255, 255, 0.3);
它在Firefox中工作得很好,但在IE8中就不行了。我怎么让它工作呢?
发布于 2010-10-20 15:44:24
创建一个大于1x1像素的png (感谢30点),它与背景的透明度相匹配。
编辑:要回退到IE6+支持,您可以为png指定bkgd块,这是一种颜色,如果它不受支持,它将替换真正的alpha透明度。你可以用gimp来修复它。
发布于 2010-10-20 19:25:30
要在IE中模拟RGBA和HSLA背景,可以使用具有相同开始和结束颜色的渐变滤镜(alpha通道是HEX值中的第一对)
background: rgba(255, 255, 255, 0.3); /* browsers */
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#4cffffff', endColorstr='#4cffffff'); /* IE */
发布于 2010-10-20 17:13:24
透明的png图像在IE 6中将不起作用,替代方案如下:
使用CSS:
.transparent {
/* works for IE 5+. */
filter:alpha(opacity=30);
/* works for IE 8. */
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
/* works for old school versions of the Mozilla browsers like Netscape Navigator. */
-moz-opacity:0.3;
/* This is for old versions of Safari (1.x) with KHTML rendering engine */
-khtml-opacity: 0.3;
/* This is the "most important" one because it's the current standard in CSS. This will work in most versions of Firefox, Safari, and Opera. */
opacity: 0.3;
}
或者直接使用jQuery:
// a crossbrowser solution
$(document).ready(function(){
$(".transparent").css('opacity','.3');
});
https://stackoverflow.com/questions/3975688
复制相似问题