我可以在 IE 中使用带渐变的透明色吗?
我试过了
filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=transparent, endColorstr=red);
奇怪的是,即使在 IE9 中,这也会创建从蓝色到黑色的渐变。
最佳答案
没有提到 (start|end)ColorStr
属性支持“透明”值。对于 Internet Explorer 8 及以下版本,您可以尝试以下代码:
.transparentGradient {
/* The element needs layout */
zoom: 1;
filter: progid:DXImageTransform.Microsoft.gradient(
gradientType=1, startColor=0, endColorStr=#FFFFFF
);
-ms-filter: progid:DXImageTransform.Microsoft.gradient(
gradientType=1, startColor=0, endColorStr=#FFFFFF
);
}
这是 a working example .我已经在 IE8 及其兼容模式和 IE6 中对其进行了测试。
开始颜色/结束颜色
startColor
和 endColor
参数接受:
Integer that specifies or receives the color value that can range from 0 (transparent) to 4294967295 (opaque white).
参见:http://msdn.microsoft.com/en-us/library/ms532929(v=vs.85).aspx
开始颜色结构/结束颜色结构
您还可以使用 startColorStr
或/和 endColorStr
接受:
String that specifies or receives a value that can range from #FF000000 to #FFFFFFFF.
因此您可以指定“#RRGGBB”(如示例中)或“#AARRGGBB”格式的颜色,后者定义为:
Color is expressed in #AARRGGBB format, where AA is the alpha hexadecimal value, RR is the red hexadecimal value, GG is the green hexadecimal value, and BB is the blue hexadecimal value. The alpha value controls the opacity of the object. An alpha value of 00 is transparent, while a value of FF is opaque.
默认值为 #FF0000FF
(不透明蓝色),如果您传递的值超出范围,则默认为该值。请参阅:http://msdn.microsoft.com/en-us/library/ms532930(v=vs.85).aspx
不要忘记:
An object must have layout for the filter to render.
参见:http://msdn.microsoft.com/en-us/library/ie/ms530752(v=vs.85).aspx
关于CSS渐变,IE中的透明颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14663569/