How to Blur a Parent Div Without Affecting Child Elements (CSS-Only Solution)
When applying CSS filters like blur or opacity to a parent div, child elements within it may also be affected. To solve this issue without using absolute positioning, consider the following solution:
Create Separate Divs for Background and Content:
Position Background Div Absolutely:
Add Blur to Background Div:
Example:
#parent_div { position: relative; width: 100px; height: 100px; } #background { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: red; filter: blur(3px); z-index: -1; }
<div>
By using this method, the background image can be blurred without affecting the child div containing the content.
The above is the detailed content of How to Blur a Parent Div's Background Without Affecting Child Elements Using Only CSS?. For more information, please follow other related articles on the PHP Chinese website!