简体   繁体   English

在IE9中使用滤镜在背景图像上实现渐变叠加

[英]Using Filters to achieve Gradient Overlay on Background Image in IE9

I am currently trying to create a gradient overlay on a background image loaded from a URL. 我目前正在尝试在从URL加载的背景图像上创建渐变叠加层。 I've got this working in most major browsers by using 通过使用,我已经在大多数主流浏览器中都可以使用

background: linear-gradient(rgba(54, 91, 162, 0.66), rgba(78, 150, 231, 0.66)), url(<urlHere>);

Now I know that IE9 does not support CSS Gradient, but it does however support the Filter property, which allows for both Image Loading and Gradients. 现在,我知道IE9不支持CSS渐变,但是它确实支持Filter属性,该属性允许图像加载和渐变。 Now according to this StackOverflow post along with the Microsoft Developer Network you can have multiple filters by separating them with a space . 现在根据这个 StackOverflow的职位与沿微软开发者网络 ,你可以通过用分离具有多个过滤器space So I tried to make my IE9 filter like so 所以我试图像这样使我的IE9过滤器

filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#a8365ba2', EndColorStr='#a84e96e7') progid:DXImageTransform.Microsoft.AlphaImageLoader(src='<urlHere>');

However I cannot seem to get this to work correctly in IE9, it will always display just the Background Image without any gradient at all, even if I reverse the order of them in the filter. 但是我似乎无法使它在IE9中正常工作,即使我在滤镜中颠倒了它们的顺序,它也将始终仅显示背景图像而没有任何渐变。

I have tested the gradient filter by itself and I know that it works, I have also tested the Background Image filter by itself and can confirm it works too. 我已经单独测试了渐变滤镜,并且知道它可以工作,还测试了背景图像滤镜,并且可以确认它也可以工作。

What am I doing wrong? 我究竟做错了什么?

您可以使用background-image: url():before/:after进行渐变。

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

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