简体   繁体   English

CSS筛选器无法在Firefox或IE中运行

[英]CSS filter not working in Firefox or IE

I'm trying to use a CSS filter to blur an image on hover. 我正在尝试使用CSS过滤器来模糊悬停时的图像。 The image is contained in a button. 该图像包含在一个按钮中。 It works in Opera, Chrome, and Edge. 它可以在Opera,Chrome和Edge中使用。 It doesn't work in Firefox or IE. 它在Firefox或IE中不起作用。 If I put the filter on the button itself it works in all the browsers, but I'd prefer for only the image to blur. 如果将滤镜放在按钮本身上,则它可以在所有浏览器中使用,但我只希望图像模糊。 Any help would be appreciated. 任何帮助,将不胜感激。 CSS 的CSS

button>img:hover {
  filter: blur(2px);
}

HTML 的HTML

  <button type="button">
    <img src="http://factory38.com/gallery-images/tree_thumb.jpg" width="200" alt="tree">
</button>

Demo 演示版

https://codepen.io/mrsmith71/pen/wjYoOY https://codepen.io/mrsmith71/pen/wjYoOY

filter seems to be at experimental stage and lacks of support for some browsers. filter似乎处于实验阶段,缺乏对某些浏览器的支持。

However the cause seems different here, on Firefox where i tested, the image is not considered hovered, it's the button that is, so that this will work ( :hover is on button instead of image): 但是这里的原因似乎有所不同,在我测试过的Firefox上,图像不被认为是悬停的,而是按钮,因此它将起作用( :hover在按钮上而不是图像上):

 button:hover img { filter: blur(2px); } button{ width: 300px; background: repeating-linear-gradient( 45deg, #606dbc, #606dbc 10px, #465298 10px, #465298 20px ); } 
 <button type="button"> <img src="http://factory38.com/gallery-images/tree_thumb.jpg" width="200" alt="tree"> </button> 

Edit : tested and works on Firefox, Chrome and Edge 编辑 :经过测试,可在Firefox,Chrome和Edge上使用

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

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