【问题标题】:filter in IE8 doesn't work, fix rgba in IE8IE8 中的过滤器不起作用,修复 IE8 中的 rgba
【发布时间】:2016-03-15 19:06:03
【问题描述】:

我需要在 IE8 中使用 rgba(alpha) 做背景色,但我的代码不起作用 HTML:

<div class="container">
    <div class="child">
    </div>
</div>

CSS:

.container {
    position: fixed; 
    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#99000000,endColorstr=#99000000);
}
.child {
    width: 50px;
    height: 50px;
    color: red;
}

【问题讨论】:

    标签: html css filter internet-explorer-8 rgba


    【解决方案1】:

    由于 IE8 确实支持 rgb() 作为背景颜色,因此结果是一个纯色框。

    因此我们需要在 rgb 规则之后将背景设置回透明(仅在 IE8 及以下)。经过更多谷歌搜索,答案是backslash 9 hack

    #div{
        background:rgb(255,0,0);
        background: transparent\9;
        background:rgba(255,0,0,0.3);
        filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#4cFF0000,endColorstr=#4cFF0000);
        zoom: 1;
    }
    #div:nth-child(n) {
        filter: none;
    }
    

    更多,请关注教程http://rland.me.uk/cross-browser-alpha-transparent-background-10-2011

    【讨论】:

    • 对我来说,没有任何背景颜色的 div 不起作用
    猜你喜欢
    • 2013-05-03
    • 1970-01-01
    • 1970-01-01
    • 2014-01-28
    • 1970-01-01
    • 2013-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多