works as expected, but I would use it as a whole webpage background (applying it to body element), and not a background of a single div.
How should I do?
I guess that a solution could be use a blurred image as background of the html element and a non blurred image as background of the body element, with a body a given max-width.
I’m confused. Why would you want to do something like this? Have a blurred background with a focused background on top of it with content on top of that, hiding the focused content…
I guess I’m not understanding what you’re trying to do…
In a my website I have a background image too little to cover the whole window width. Therefore I had to stretch it out, deforming it a bit.
With a blur effect, I could both 1) keep the “natural” with of the background image and 2) cover the whole window size (with lateral blurred pieces of the background image).
I don’t know if it is clear (excuse for my poor English).
You couldn’t just use cover in your css which resizes your image automatically to fill the space? Can you see that much of the background image to worry about deformation of it?
You can just use :before and :after and no image at all.
You have to be careful when mixing background-size:cover and background-attachment fixed as it doesn’t work in mobile and the whole document gets covered not just the viewport. That’s why I use a fixed pseudo element instead to avoid that issue. I’m assuming that you did what the image fixed to the viewport as not 100% sure of your use case.
So far I have troubles with the content (divs) of body. The background is almost OK (with the blur effect almost as expected), but “foreground”, so far, no.