【问题标题】:rgba not working in IE8 how to solve thisrgba 在 IE8 中不起作用如何解决这个问题
【发布时间】:2014-01-28 04:00:21
【问题描述】:

我知道 rgba 不能在 ie8 浏览器中工作。我该如何解决这个问题。

请参考下面的html

<html>
<head>
<style type="text/css">
body
{
background-color:black;
}
.navitem
{
color:red;
}
.navitem:hover
{
 background: rgba(255, 255, 255, 0.3); /* browsers */
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#4cffffff', endColorstr='#4cffffff'); /* IE */

}
</style>
</head>
<body>
<a class="navitem">Hot Alerts</a>
</body>


</html>

我用谷歌搜索并在下面的链接中找到了解决方案,我尝试使用该解决方案但仍然无法正常工作。我该如何解决这个确切的问题。

我提到的以下链接。

CSS background opacity with rgba not working in IE 8

谢谢,

湿婆

【问题讨论】:

  • 在 IE 中没有任何作用,你为什么在乎?
  • 没有解决这个问题,颜色在旧版浏览器中没有 alpha 通道,除了将 rgba 值转换为 rgb 或 hex 之外,不能真正对其进行 polyfill。

标签: javascript html css internet-explorer-8


【解决方案1】:

您可以使用 .png 作为背景图片,或者只为 IE8 设置纯色后备。后备的工作方式如下:

.navitem:hover {
    /* solid color fallback */
    background: rgb(100,100,100);
     /* modern browsers */
    background: rgba(255, 255, 255, 0.3);
}

【讨论】:

  • 有什么有用的例子吗?
  • 查看我的更新。声明的第一个颜色不会是透明的,但仅用于 IE8 及以下版本。您可以调整它以使其看起来尽可能接近透明颜色。所有现代浏览器都将获得具有透明度的第二个值。或者,如果您想使用 png 方法,只需创建一个不透明度为 30% 的白色 png 并将其称为背景图像。我相信这会回到 IE7。
【解决方案2】:

我使用这个站点为 IE 8 生成 rgba 并且可以工作:http://kimili.com/journal/rgba-hsla-css-generator-for-internet-explorer/

请尝试。在第一个字段中键入这样的:“rgba(0,0,0,0.5)” 输出是您在 IE 中使用的代码

【讨论】:

  • 怎么样?当然可以,我在这里在 Windows XP 上运行的 Internet Explorer 8 中进行了测试。你可以给我看完整的代码吗?
  • +1 但我也会将生成的代码示例放入您的答案中。链接将来可能会损坏!
猜你喜欢
  • 2013-05-03
  • 1970-01-01
  • 1970-01-01
  • 2011-04-30
  • 2022-01-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-09-28
相关资源
最近更新 更多