How can I blur the background?

<body> <div></div> </body> 

I want the page background to be blurred. The image is set as background-img. As I understand it, filters (filter css) can only be applied to pictures.


ps. I did not find the right question because everywhere asked about img tag.

    2 answers 2

    If you apply blur to the body , then the entire content of the page will be blurry.

    To avoid this, you can render the background in a new div with position:absolute , and wrap the rest of the content into another div with position:relative and z-index higher than the block with the background:

     .content { position: relative; z-index: 2; color: #fff; } .bg { position: absolute; z-index: 1; left: -10px; top: -10px; right: -10px; bottom: -10px; filter: blur(5px); background: url(http://files.all-free-download.com//downloadfiles/wallpapers/1920_1080/tropical_beach_paradise_5k_17484.jpg) no-repeat center; background-size: cover; } 
     <body> <div class="bg"></div> <div class="content"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. </div> </body> 

    • Thank you, so I presented the solution, but it seemed strange. =) - EpicLegend
     .selector { filter: blur(3px); } 

    http://joxi.ru/5mdMJp3hkQpgv2

    Background Blur Effect / Frosted Glass Effect - CSS