Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grayscale not working with LESS

Tags:

grayscale

less

I want to use the grayscale function but LESS keeps throwing this error and I don't see a mixin for grayscale or how to use it. Any help?

Error   148 Expected color in function 'grayscale'

 img {
     -webkit-filter: blur(2px) grayscale(1);
    -moz-filter: blur(2px) grayscale(1);
    -o-filter: blur(2px) grayscale(1);
    -ms-filter: blur(2px) grayscale(1);
    filter: blur(2px) grayscale(1);
 }
like image 254
Mike Flynn Avatar asked Dec 21 '25 09:12

Mike Flynn


1 Answers

Try the following. LESS is probably not recognizing grayscale(1) as a valid function for itself, but also not seeing is as a property value, so that is when you need to use string interpolation to get LESS to compile nicely.

 img {
    @filterString: ~"blur(2px) grayscale(1)";

     -webkit-filter: @filterString;
    -moz-filter: @filterString;
    -o-filter: @filterString;
    -ms-filter: @filterString;
    filter: @filterString;
 }
like image 94
ScottS Avatar answered Dec 24 '25 10:12

ScottS



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!