简体   繁体   English

IE 8+中的CSS渐变可在网站的所有部分工作,但其中一个除外

[英]CSS Gradients in IE 8+ working on all parts of the site except one

While testing browser compatibility for a site that I'm designing currently, I found that CSS Gradients are working fine on all parts of the site except the navigation links in IE 8 and IE 9. 在测试我当前正在设计的网站的浏览器兼容性时,我发现CSS Gradients在该网站的所有部分都能正常工作,但IE 8和IE 9中的导航链接除外。

I'm using the 'filter' property for that. 我为此使用'filter'属性。 The HTML structure of the nav is 导航的HTML结构是

<ul id="nav"><li><a>Some Name</a></li></ul>

and the CSS for the element is, 元素的CSS是,

#nav li a
{
background: rgb(191,82,0);
background: -moz-linear-gradient(top, rgb(191,82,0) 0%, rgb(124,51,0) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgb(191,82,0)), color-stop(100%,rgb(124,51,0)));
background: -webkit-linear-gradient(top, rgb(191,82,0) 0%,rgb(124,51,0) 100%);
background: -o-linear-gradient(top, rgb(191,82,0) 0%,rgb(124,51,0) 100%);
background: -ms-linear-gradient(top, rgb(191,82,0) 0%,rgb(124,51,0) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bf5200', endColorstr='#7c3300',GradientType=0 );
background: linear-gradient(top, rgb(191,82,0) 0%,rgb(124,51,0) 100%);
position: relative;
height: 1.3em;
padding: 0.2em 2em 0.1em 2em;
color: #FFF;
font-size: 0.9em;
font-family: FertigoProRegular;
text-transform: uppercase;
border-radius: 1em;
box-shadow: 0em 0em 0.5em #aaa;
border-bottom: 3px solid #5C2600;
}

I tried assigning a specific ID to the nav links and then apply the CSS to it. 我尝试为导航链接分配一个特定的ID,然后将CSS应用于它。 But that didn't work out. 但这并没有解决。 I know PIE and other such HTC behavior elements would work. 我知道PIE和其他此类HTC行为元素会起作用。 But I want to know why exactly it's not working only in that area. 但是我想知道为什么它不仅仅在那个领域起作用。

First I thought that it's a problem which occurs with all <a> elements. 首先,我认为这是所有<a>元素都会出现的问题。 But that wasn't the case either as the Gradients displayed perfectly on other <a> elements on the site. 但是事实并非如此,因为“渐变”可以完美显示在网站上的其他<a>元素上。 The problem is limited to the nav links. 问题仅限于导航链接。

Any help would be appreciated. 任何帮助,将不胜感激。

when i doing a gradient menu i always use Ultimate CSS Gradient Generator 当我做渐变菜单时,我总是使用Ultimate CSS Gradient Generator

Outputs older Internet Explorer opacity format (yes, this will even work with IE6! 输出较旧的Internet Explorer不透明格式(是的,甚至可以在IE6上使用!

Your code is OK. 您的代码正常。 Just tried it in my IE8. 刚刚在我的IE8中尝试过。 The only problem is your colors. 唯一的问题是您的颜色。 If you change start or end color of your filter you will see the difference; 如果您更改filter开始或结束颜色,您将看到区别。

If you change your filter to: 如果将过滤器更改为:

filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bf5200', endColorstr='#7c33ee',GradientType=0 );

See in action http://jsbin.com/icenuk 观看实战http://jsbin.com/icenuk

You will see the code is working actually. 您将看到代码实际上正在工作。 It's the Ultimate CSS generator or IE DXImageTransform gradient issue that they don't produce same gradient as standard CSS gradient. 这是Ultimate CSS生成器或IE DXImageTransform渐变问题,它们不会产生与标准CSS渐变相同的渐变。 You may need to change the colors manually in the filter to get what you want. 您可能需要手动更改滤镜中的颜色以获得所需的颜色。 Or you can use another gradient generator like this : 或者你可以使用另一个梯度发生器像这样

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM