How Can I Blur Text In A Square Using Pseudo Selectors?
I want to add blur behind text up to some amount of padding. I don't want some div behind and blur the div, I want it to be bound to the text. Here is my attempt: I am getting lik
Solution 1:
You can consider overflow:hidden
to stop the blur effect and have a sharpe edge. I also considered padding instead of adjusting top/left/right/bottom:
.container {
width: 400px;
height: 200px;
position: relative;
overflow: hidden;
}
.text {
z-index: 1;
position: absolute;
width: auto;
bottom: 24px;
left: 24px;
font-size: 36px;
padding: 12px22px; /*added this*/overflow: hidden; /*added this*/
}
.text::before {
content: "";
position: absolute;
z-index: -1;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: red;
opacity: 0.4;
filter: blur(10px);
}
<divclass="container"><h1class="text">Example Text</h1></div>
Post a Comment for "How Can I Blur Text In A Square Using Pseudo Selectors?"