Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

CSS filter one background image on an element that has multiple background images

I’ve got an element with this css. It works great, but I want to blur the image that is set to cover. I can’t find a way to apply filters to just one background image. I realize I could probably set it up with ::before or ::after, but I was really hoping there was a clean solution to make it part of the css one-liner here. I did some research, but didn’t find any information about this. Is there some fancy css wizardry nowadays that can do this?

background: url($img) center/contain no-repeat, url($img) center/cover;

I’m hoping to be able to do something like this:

background: url($img) center/contain no-repeat, url($img) center/cover blur(20px);

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

What you want can be done like below using filter()

background: 
  url($img) center/contain no-repeat,
  filter(url($img), blur(20px)) center/cover;

But no browser support for this right now: https://caniuse.com/css-filter-function

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading