css - Blurring background without restructuring html? -
i trying apply css blur property wrapper div, don't want affect text. framework using difficult restructure html. there way blue background , not text?
html structure
<div class="wrapper"> <h1>hello world</h1> </div>
css
.wrapper{ -webkit-filter: blur(5px); -moz-filter: blur(5px); -o-filter: blur(5px); -ms-filter: blur(5px); filter: blur(5px); background-color:red; }
if point me direction of solution, if there one, appreciated.
it's perhaps worth noting can't blur backgrounds...only elements.
so, pseudo-element answer here.
.wrapper { position: relative; } .wrapper::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; -webkit-filter: blur(5px); -moz-filter: blur(5px); -o-filter: blur(5px); -ms-filter: blur(5px); filter: blur(5px); background-color: red; z-index: -1; }
<div class="wrapper"> <h1>hello world</h1> </div>
Comments
Post a Comment