CSS radial gradient on ie8 and ie9

2019-08-26 22:02发布

问题:

Is there a way to make the following work on ie8 and ie9?

Thanks

background: -moz-moz-radial-gradient(center top, farthest-side, rgba(175,175,175,0.3) 0%, rgba(255,255,255,0) 100%); /* FF3.6+ */
background: -webkit-gradient(radial, center top, farthest-side, 0px, center top, farthest-side, 100%, color-stop(0%,rgba(255,255,255,1)), color-stop(100%,rgba(255,255,255,0))); /* Chrome,Safari4+ */
background: -webkit-radial-gradient(center top, farthest-side, rgba(175,175,175,0.3) 0%,rgba(255,255,255,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-radial-gradient(center top, farthest-side, rgba(175,175,175,0.3) 0%,rgba(255,255,255,0) 100%); /* Opera 12+ */
background: -ms-ms-radial-gradient(center top, farthest-side, rgba(175,175,175,0.3) 0%,rgba(255,255,255,0) 100%); /* IE10+ */
background: radial-gradient(farthest-side at center top, rgba(175,175,175,0.3) 0%,rgba(255,255,255,0) 100%); /* W3C */

回答1:

I note that you've got a problem in the CSS in the question where you've doubled up the -moz- and -ms- prefixes. Those definitely won't work like that.

Ignoring that, you're right that radial gradients are a problem in old IE. In fact, CSS gradients in general are problematic in old IE versions because CSS gradients are not supported in IE 9 or earlier.

My normal solution to CSS gradients in IE 6-9 is CSS3Pie.

However for radial gradients this isn't sufficient, because CSS3Pie doesn't currently support radial gradients. See the css3pie documentation for more info on this. To quote:

Radial gradients are not supported at this time; this feature is planned for a future release (see issue #2) but it may turn out to be impossible to implement in IE 6-8 due to VML's strange radial gradient behavior.

The other option you have is to use IE's filter style, (and accept all the weird issues and quirks that come with it). Even here, radial gradients are difficult, but there is a solution here that might help: Create a radial gradient for Internet Explorer 6/7/8