I have these styles:
.spoiler {
pointer-events: auto;
position: relative;
}
.spoiler::after {
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
content: "";
background-color: rgb(20, 20, 20);
transition: opacity 250ms;
}
.spoiler:hover::after {
opacity: 0.25;
}
It works fine when text is not wrapped like here
But if it’s wrapped it doesn’t work properly
- Reduced stage requirement for <span class="spoiler">light</span>. <br>
- <span class="spoiler">Light upgrade 3 is now much stronger: starting effect is 100ms, max level is 20, cost scaling is 2</span>.
So how can I cover the entire span with ::after
?
2
Answers
You need to "blockify" the
span
by adding a suitabledisplay
value.Perhaps,
inline-block
orinline-flex
?Set
.spoiler { background-color: currentColor; }
and change it on:hover
: