Search code examples
cssfilterbackgroundblur

I want to blur the back surface using filtering and make the middle part normal


<style> 
.Parallax{
    width:100vw;
    height: 100vh;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}
.ImageLayer {
    width: 80%;
    height: 80%;
    backdrop-filter:blur(10px);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}       
</style>
          
<div class="Parallax" style="background-image: url('https://images.pexels.com/photos/2478248/pexels-photo-2478248.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1')">
     <div class="ImageLayer"></div>
</div>
        

The output of the code makes the middle part blurry, and I want to do the opposite.

I tried a few times but it didn't turn out the way I wanted. I wrote this code just as an example


Solution

  • Perhaps you'll need another layer of image

    .Parallax-blur {
      position: relative;
      width: 100vw;
      height: 100vh;
      background-repeat: no-repeat;
      background-size: cover;
      background-position: center;
      background-image: url('https://images.pexels.com/photos/2478248/pexels-photo-2478248.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1');
      filter: blur(10px);
      clip-path: polygon(0% 0%, 0% 100%, 25% 100%, 25% 25%, 75% 25%, 75% 75%, 25% 75%, 25% 100%, 100% 100%, 100% 0%);
    }
    
    .Parallax {
      position: absolute;
      width: 100vw;
      height: 100vh;
      top: 0;
      left: 0;
      background-repeat: no-repeat;
      background-size: cover;
      background-position: center;
      background-image: url('https://images.pexels.com/photos/2478248/pexels-photo-2478248.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1');
      z-index: 1;
    }
    
    .ImageLayer {
      width: 80%;
      height: 80%;
      position: absolute;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      z-index: 2;
    }
    <div class="Parallax">
      <div class="Parallax-blur">
        <div class="ImageLayer"></div>
      </div>
    </div>

    For clip-path values, check here:

    https://bennettfeely.com/clippy/