Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Filter not working in Firefox

Tags:

html

css

I am trying CSS filter but it does not work in my Firefox (15.0) browser.

HTML:

<div class="google">      <img src="https://www.google.com/images/srpr/logo3w.png"> </div> 

CSS:

.google{        -moz-filter: grayscale(100%);     filter: grayscale(100%); } 

Demo: http://jsfiddle.net/xDJzU/

like image 882
user1251698 Avatar asked Aug 29 '12 07:08

user1251698


People also ask

Why backdrop filter not working in Firefox?

Why backdrop filter in Firefox doesn't work? Firefox does not support the backdrop filter feature by default and hence, you will have to enable it. However, it can be enabled in Firefox versions 70 and above manually and is available by default in versions 102 and above.


2 Answers

GrayScale has limitations to work in firefox using a -moz-filter.

To get it working use the below snippet:

filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 3.5+ */ 

DEMO

like image 199
defau1t Avatar answered Sep 18 '22 16:09

defau1t


Rewrite your css code with this one, assuming that you're trying to achieve a grayscale image:

.google{     filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 3.5+ */     filter: gray; /* IE6-9 */     -webkit-filter: grayscale(100%); /* Chrome 19+ & Safari 6+ */ } ​ 

Updated jsfiddle: jsfiddle link

like image 30
aspirinemaga Avatar answered Sep 17 '22 16:09

aspirinemaga