rgba()的颜色IE后备不工作 [英] color IE fallback for rgba() does not work

查看:161
本文介绍了rgba()的颜色IE后备不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么IE color:red; 不能正常工作?

在IE7中,颜色为黑色而不是红色

在此演示

Why the following fallback for IE color: red; does not work ?
In IE7, the color is black rather than red.
Live demo here

HTML:

<div>
    <span>Hello</span>
</div>

CSS:

div {
    width: 200px;
    height: 100px;
    background-color: blue;
    text-align: center;
}
span {
    font-size: 2em;
    color: red;
    color: rgba(250, 250, 97, 0.9);
}


推荐答案

但是,因为它看到你的颜色:style,它会尝试评估它并恢复为默认颜色(#00000000)。
您可以在此使用IE特定的黑客,例如

However, as it sees your color: style, it attempts to evaluate it and reverts to the default color (#00000000). You could use an IE specific hack here, such as

*color: red;

但是,假设你试图只影响背景颜色,而不是整个不透明度元素,最好使用一个过滤器,将所需的rgba值设置为渐变的开始和结束颜色 - 创建rgba背景。

But, assuming that you are trying to affect only the background color, and not the opacity of the entire element, you're best off with a filter that sets the desired rgba value as the start and end color of a gradient - creating an rgba background.

filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000050,endColorstr=#99000050);

-ms-filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000050,endColorstr=#99000050);

但是请记住 - IE假设Alpha是第一个,不是最后一个,所以不要只是转换和复制您的值。
双过滤器分别用于IE6和IE7。

But remember - IE assumes that the Alpha is first, not last, so don't just convert and copy your values. The double filter is for IE6 and IE7 respectively.

http://css-tricks.com/rgba-browser-support/

这篇关于rgba()的颜色IE后备不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆