Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove blur effect on child element

Tags:

I have a <div> with an background-image with blur effect.

-webkit-filter: blur(3px); -moz-filter: blur(3px); -o-filter: blur(3px); -ms-filter: blur(3px); filter: blur(3px); 

The only problem is that all the Child elements also get the blur effect. Is it possible to get rid of the blur effect on all the child elements??

<div class="content">     <div class="opacity">         <div class="image">             <img src="images/zwemmen.png" alt="" />         </div>         <div class="info">              a div wih all sort of information         </div>     </div> </div>       .content{         float: left;         width: 100%;         background-image: url('images/zwemmen.png');         height: 501px;         -webkit-filter: blur(3px);         -moz-filter: blur(3px);         -o-filter: blur(3px);         -ms-filter: blur(3px);         filter: blur(3px);     }      .opacity{         background-color: rgba(5,98,127,0.9);         height:100%;         overflow:hidden;     } .info{     float: left;     margin: 100px 0px 0px 30px;     width: 410px; } 

http://jsfiddle.net/6V3ZW/

like image 464
Robert Verkerk Avatar asked Mar 14 '14 13:03

Robert Verkerk


People also ask

How to blur CSS div without blur child element?

Set position:relative on the parent div and set position:absolute; top:0px; right:0px; bottom:0px; left:0px; (or set height/width to 100%) to the child element for the background. Using this method, the content div will not be affected by properties on the background.

How do you blur content behind an element?

backdrop-filter: blur(10px); It will blur area behind the element.


2 Answers

Create a div inside content & give bg image & blur effect to it. & give it z-index less the the opacity div, something like this.

<div class="content">     <div class="overlay"></div>     <div class="opacity">         <div class="image">             <img src="images/zwemmen.png" alt="" />         </div>         <div class="info">              a div wih all sort of information         </div>     </div> </div> 

Use Css

.content{     float: left;     width: 100%; }  .content .overlay{     background-image: url('images/zwemmen.png');     height: 501px;     -webkit-filter: blur(3px);     -moz-filter: blur(3px);     -o-filter: blur(3px);     -ms-filter: blur(3px);     filter: blur(3px);     z-index:0; }  .opacity{     background-color: rgba(5,98,127,0.9);     height:100%;     overflow:hidden;     position:relative;     z-index:10; } 
like image 180
demonofthemist Avatar answered Sep 22 '22 13:09

demonofthemist


Add an overlay something like this:

<div class="overlay"></div> 

Then:

.overlay {   position: fixed;   top: 0;   left: 0;   width: 100%;   height: 100%;   backdrop-filter: blur(2px) sepia(50%);   z-index: 9999999999999999999; } 

Here the parent child relationship is not what matters. The z-index is important.

It will apply the filter to anything sitting behind the div.

like image 35
danday74 Avatar answered Sep 19 '22 13:09

danday74