簡體   English   中英

IE8中的過濾器不起作用,請修復IE8中的rgba

[英]filter in IE8 doesn't work, fix rgba in IE8

我需要在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;
}

由於IE8確實支持rgb()作為背景顏色,因此結果是一個純色框。

因此,我們需要根據rgb規則(僅在IE8及更低版本中)將背景設置回透明狀態。 經過更多谷歌搜索,答案是反斜杠9黑客

#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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM