1

我在这里测试带圆角的半透明背景(CSS 在 HTML 中):

http://www.lucagiorcelli.it/test/milanificio_boxes/

它们在 IE10 中很好(见截图: http: //o7.no/KSvX2b)。但在 IE9 中它们更暗,角落有鬼影(见截图: http: //o7.no/KSw9P2)。

我的 CSS 有什么问题?

.yellowAlpha35 {
/* Fallback for web browsers that doesn't support RGBa */
background: rgb(245, 221, 183);
filter:alpha(opacity=35);
/* RGBa with 0.6 opacity */
background: rgba(241, 144, 28, 0.35);
/* For IE 5.5 - 7*/
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#23000000, endColorstr=#23000000);
/* For IE 8*/
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#23000000, endColorstr=#23000000)";
}
4

3 回答 3

1

据我记得 -ms-filter 在 IE9 中仍然有效,它只是被标记为已弃用。因此,在 IE9 中,您可以使用 rgba() + IE8 所需的渐变来获得背景。

要解决此问题,您可以为 IE8、IE9 等创建单独的 CSS 文件,或者只使用 CSS hack。例如 :root 是在 IE9 中引入的,所以你可以使用

:root .yellowAlpha35 {
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient(enabled=false)";
}

这比准备多个 CSS 文件并使用条件注释添加它们更容易,除非您有更多的 IE 版本特定规则。

于 2012-05-10T12:00:15.343 回答
0

正如 Rafaei 所说,ms-filter 在 IE9 中仍然有效,它只是被标记为已弃用。为避免此类事情发生,请根据浏览器使用多个 CSS 填充。这样,您可以将 -ms-filter 部分保留在 IE9+ 中,而在 IE 8 中仍然保留它。所以:

<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="ie8.css" />
<![endif]-->

<!--[if !(IE 8)]>
<link rel="stylesheet" type="text/css" href="style.css" />
<![endif]-->

更多信息链接

于 2012-05-10T12:09:44.210 回答
-1

I assume you've run the acid tests against the browser?

http://www.acidtests.org/

于 2012-05-10T12:05:09.767 回答