简体   繁体   English

在IE9中使用CSS3 PIE的线性渐变不起作用,IE8可以

[英]linear-gradient using CSS3 PIE in IE9 not working, IE8 does

I've decided to completely drop support for IE6 and IE7 in my website, redirecting it's users to a text-only warning page. 我决定在我的网站上完全放弃对IE6和IE7的支持,将其用户重定向到纯文本警告页面。 However I still support IE8 and IE9. 但是我仍然支持IE8和IE9。

I am achieving this using CSS3 PIE , and border-radius works in both (IE8/9), box-shadow works in both, however I also rely on linear-gradient. 我使用CSS3 PIE来实现这一点,并且border-radius在两个(IE8 / 9)中工作,盒子阴影在两者中都有效,但是我也依赖于线性渐变。 I have heaps of tags in use to achieve this: 我有大量标签用于实现此目的:

background: #E6E6E6; /* fallback */
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#E6E6E6), to(#B3BCC7)); /* old webkit */
background: -webkit-linear-gradient(#E6E6E6, #B3BCC7); /* new webkit */
background: -moz-linear-gradient(#E6E6E6, #B3BCC7); /* firefox */
background: -ms-linear-gradient(#E6E6E6, #B3BCC7); /* meant to be IE... */
background: filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#E6E6E6', endColorstr='#B3BCC7'); /* also meant to be IE... */
background: -o-linear-gradient(#E6E6E6, #B3BCC7); /* opera */
background: linear-gradient(#E6E6E6, #B3BCC7); /* W3C standard */
-pie-background: linear-gradient(#E6E6E6, #B3BCC7); /* PIE */

behavior: url(/PIE.htc); /* load PIE.htc */

linear-gradient works in IE8, but not IE9, oddly. 奇怪的是,线性渐变在IE8中起作用,但在IE9中起作用。 I've tried any solutions I've found, but they haven't worked. 我已经尝试过我找到的任何解决方案,但它们没有用。 IE8 just shows the fallback: background: #E6E6E6; IE8只显示了后备: 背景:#E6E6E6; - not a gradient. - 不是渐变。

I don't think it's anything wrong with the server or anything like that, because the other properties - border-radius and box-shadow - work with PIE but not without. 我不认为服务器或类似的东西有什么问题,因为其他属性 - border-radiusbox-shadow - 与PIE一起工作但不是没有。

I've got all the properties to work in all browsers I support - just not IE9 :( 我有所有的属性在我支持的所有浏览器中工作 - 只是没有IE9 :(

Any ideas? 有任何想法吗?
Thanks 谢谢

OK, here's my fix. 好的,这是我的修复。 It certainly isn't pretty, but it works. 它当然不漂亮,但它的工作原理。

<style type="text/css">
body{
  background: #E6E6E6;
  background: -webkit-gradient(linear, 0 0, 0 bottom, from(#E6E6E6), to(#B3BCC7));
  background: -webkit-linear-gradient(#E6E6E6, #B3BCC7);
  background: -moz-linear-gradient(#E6E6E6, #B3BCC7);
  background: -ms-linear-gradient(#E6E6E6, #B3BCC7);
  background: -o-linear-gradient(#E6E6E6, #B3BCC7);
  background: linear-gradient(#E6E6E6, #B3BCC7);
  -pie-background: linear-gradient(#E6E6E6, #B3BCC7);

  behavior: url(/PIE.htc); 
}
</style>

<!--[if IE 9]><style>body{ filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#E6E6E6', endColorstr='#B3BCC7'); behavior: url(/ie9-gradient-fix.htc); } </style><![endif]-->

EDIT: If anybody wants them, PIE.htc is found at http://www.css3pie.com and ie9-gradient-fix.htc is found at http://abouthalf.com/examples/ie9roundedbackgrounds/htc.zip . 编辑:如果有人想要它们,可以在http://www.css3pie.com找到PIE.htc,在http://abouthalf.com/examples/ie9roundedbackgrounds/htc.zip找到ie9-gradient-fix.htc。 I couldn't get ie9-gradient-fix.htc to work unless it was in the root directory, PIE.htc worked in my /resources/ directory. 我无法使ie9-gradient-fix.htc工作,除非它在根目录中,PIE.htc在我的/ resources /目录中工作。

I don't think it's anything wrong with the server or anything like that, because the other properties - border-radius and box-shadow - work with PIE but not without. 我不认为服务器或类似的东西有什么问题,因为其他属性 - border-radius和box-shadow - 与PIE一起工作但不是没有。

PIE does not render border-radius and box-shadow in IE9 since IE9 supports both of those natively. 由于IE9本身支持这两种,因此PIE不会在IE9中渲染border-radius和box-shadow。 So their presence is not an indication that PIE is working. 所以他们的存在并不表示PIE正在发挥作用。

My guess is actually that your PIE.htc is being served with the incorrect content-type header -- IE9 is particularly strict about the content-type. 我的猜测实际上是你的PIE.htc使用了错误的内容类型标题 - IE9对内容类型特别严格。 See http://css3pie.com/documentation/known-issues/#content-type for details. 有关详细信息,请参见http://css3pie.com/documentation/known-issues/#content-type

I was having a big headache because even with the correct content-type header (text/x-component), the linear-gradient wasn't working on IE9. 我很头疼,因为即使使用正确的内容类型标题(text / x-component),线性渐变也无法在IE9上运行。

Upgrading to PIE 2.0 solved the issue. 升级到PIE 2.0解决了这个问题。

http://css3pie.com/2013/01/28/pie-2-0-beta-1-released http://css3pie.com/2013/01/28/pie-2-0-beta-1-released

Great! 大! i used PIE.php and fixed this bug (linear-gradient + border-radius) in IE8, IE9! 我使用了PIE.php并在IE8,IE9中修复了这个bug(线性渐变+ border-radius)!

To use it, simply make sure both PIE.php and PIE.htc are in the same directory, and then in your CSS point the behavior to the PHP file instead: 要使用它,只需确保PIE.php和PIE.htc都在同一目录中,然后在CSS中指向PHP文件的行为:

behavior: url(PIE.php); 行为:网址(PIE.php);

ie9-gradient-fix.htc worked for me in IE 9 but then again changing behavior from pie.htc to pie.php ALSO does the same thing. ie9-gradient-fix.htc在IE 9中为我工作,但后来再次从pie.htc改变行为到pie.php也做了同样的事情。

The wheels turn oh so slowly at Microsoft but it appears they might also turn in opposite directions? 微软的轮子转得这么慢,但看起来它们也可能转向相反的方向?

In my case i was using <!--[if lt IE 9]> , changing it to <!--[if lt IE 10]> fixed my problem (of not actualy including my IE css file). 在我的情况下,我使用<!--[if lt IE 9]> ,将其更改为<!--[if lt IE 10]>解决了我的问题(不包括我的IE css文件)。

I think** <!--[if lte IE 9]> would do the same logic. 我认为** <!--[if lte IE 9]>会做同样的逻辑。

filter: progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#88222222', EndColorStr='#00222222', GradientType=0);

PS. PS。 I am not using css3pie whatsoever (I thought I was, derp) 我没有使用css3pie(我以为我是,derp)

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

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