CSS Background Blur Effect

CSS Background Blur Effect
Code Snippet:Blur
Author: thehuseyinoglu
Published: January 10, 2024
Last Updated: January 22, 2024
Downloads: 322
License: MIT
Edit Code online: View on CodePen
Read More

This code snippet creates a CSS background blur effect for an image. The effect is achieved by applying a blur filter to the image and then transitioning the blur amount to 0 when the user hovers over a text element.

You can apply this effect to your website’s hero section for a sleek and attention-grabbing introduction. Moreover, you can customize the code with additional CSS according to your needs.

How to Create CSS Background Blur Effect

1. Begin by integrating the following HTML code into your webpage’s body. Customize the section and add your desired content between the <h2> tags. The image source can be modified to suit your design preferences.

<body>
    <section>
        
        <h2>PARİS</h2>
        <img src=https://images.unsplash.com/photo-1609901142579-80703d2436f4?crop=entropy&cs=srgb&fm=jpg&ixid=MXwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHw&ixlib=rb-1.2.1&q=85>
        <br>
    </section>

</body>

2. Embed the following CSS code to infuse style and functionality. This code creates a background blur effect on hover. The section h2 class triggers a smooth transition, enhancing the visual experience. Adjust the font, color, and positioning according to your needs.

*
{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: poppins;
    
}
section{
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
   
}
section h2{
    position: relative;
    margin-top: 24vh;
    font-size: 13vw;
    color: white;
    font-weight: 800;
    z-index: 2;
    transition: 2s;
}
span{
    font-size: 2vw;
    
}

section h2:hover{
filter: blur(10px);
transform: scale(1.2);

}

section img{
position: absolute;
top: -20px;
left: -20%;
width: 140%;
height: 140%;
pointer-events: none;
filter: blur(20px);
transition: 2s;
}
section h2:hover ~ img{
top:0px;
left: 0px;
width: 100%;
height: 100%;
filter: blur(0px);
    
}

Update the blur effect to your liking by modifying the values in the filter: blur() property within the section h2:hover and section img sections. Experiment with different pixel values to achieve the desired level of blur. Tweak other properties like transform and transition for a personalized touch.

That’s all! hopefully, you have successfully created a CSS background Blur Effect on your website. If you have any questions or suggestions, feel free to comment below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About CodeHim

Free Web Design Code & Scripts - CodeHim is one of the BEST developer websites that provide web designers and developers with a simple way to preview and download a variety of free code & scripts. All codes published on CodeHim are open source, distributed under OSD-compliant license which grants all the rights to use, study, change and share the software in modified and unmodified form. Before publishing, we test and review each code snippet to avoid errors, but we cannot warrant the full correctness of all content. All trademarks, trade names, logos, and icons are the property of their respective owners... find out more...

Please Rel0ad/PressF5 this page if you can't click the download/preview link

X