内部DIV无法撤消外部DIV的不透明度属性。如果要实现透明度,请使用rgba
或hsla
:
外层div:
background-color: rgba(255, 255, 255, 0.9); /* Color white with alpha 0.9*/
内部div:
background-color: #FFF; /* Background white, to override the background propery*/
因为您已经添加filter:alpha(opacity=90)
了问题,所以我假设您还想要IE(旧版本)的有效解决方案。这应该可以工作(-ms-
IE的最新版本的前缀):
/*Padded for readability, you can write the following at one line:*/
filter: progid:DXImageTransform.Microsoft.Gradient(
GradientType=1,
startColorStr="#E6FFFFFF",
endColorStr="#E6FFFFFF");
/*Similarly: */
filter: progid:DXImageTransform.Microsoft.Gradient(
GradientType=1,
startColorStr="#E6FFFFFF",
endColorStr="#E6FFFFFF");
我使用了Gradient滤镜,以start-
和开头end- color
,因此背景不会显示渐变,而是显示出平坦的颜色。颜色格式为ARGB十六进制格式。我编写了一个JavaScript代码段,将相对不透明度值转换为绝对的alpha- hex值:
var opacity = .9;
var A_ofARGB = Math.round(opacity * 255).toString(16);
if(A_ofARGB.length == 1) A_ofARGB = "0"+a_ofARGB;
else if(!A_ofARGB.length) A_ofARGB = "00";
alert(A_ofARGB);