CSS渐变,IE中的透明颜色?

标签 css

我可以在 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 中对其进行了测试。

开始颜色/结束颜色

startColorendColor 参数接受:

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/

相关文章:

jquery - 固定购物车,滚动移动但不粘在页面顶部

javascript - jQuery css ("display","table-cell") 不会立即应用

javascript - 将内容/文本置于绝对 div 绝对中心;从中心变换

javascript - 在我的 div 中创建一个表的函数

html - 响应式设计模式与调整浏览器窗口大小

python - 在我的 Django 模板中,如何显示复选框和通知类型?

html - 我可以用一个div的高度来实现另一个的高度吗?

html - Bootstrap 旋转木马 500 x 500

html - 我怎样才能使两个跨度与 'display:block' 在同一行

css - Z-index with before 伪元素