CSS Blur on Background Image While Preserving Content Clarity
In an attempt to blur a background image in a CSS setting, it's common to encounter the issue where the content (text or other elements) also becomes blurred. This is where the concept of z-index and pseudo elements come into play.
To blur the background image without affecting the content, the following approach can be employed:
Below is an example code:
.blur-bgimage {
overflow: hidden;
margin: 0;
text-align: left;
}
.blur-bgimage:before {
content: "";
position: absolute;
width: 100%;
height: 100%;
background: inherit;
z-index: -1;
filter: blur(10px);
-moz-filter: blur(10px);
-webkit-filter: blur(10px);
-o-filter: blur(10px);
transition: all 2s linear;
-moz-transition: all 2s linear;
-webkit-transition: all 2s linear;
-o-transition: all 2s linear;
}
By implementing this approach, you can effectively blur the background image while preserving the clarity of your content, allowing for visually appealing website designs.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3