Here is a link to the codepen in question: https://codepen.io/dvreed77/pen/yrwjoM.
I am trying to highlight specific text with a large line gap and maintain the hover effect consistently when hovering over individual blocks of text. Currently, the highlight flashes rapidly on-off-on when moving over the whitespace between lines.
I have attempted adjusting the height and other properties, but nothing seems to solve the issue and I am a bit stuck.
The relevant CSS code can be found below:
div {
width: 90%; /* Adjusted for styling */
margin: 0 auto;
line-height: 2;
}
span {
height: 2em;
background: rgba(255, 0, 0, 0.2);
vertical-align: middle;
}
span:hover {
background: rgba(255, 0, 0, 0.5);
}
<div>
<span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi hendrerit, enim eu fermentum condimentum, nulla tellus suscipit libero, quis tincidunt eros metus sed leo.</span>
<span>Suspendisse eu augue lectus.</span>
<span>Sed aliquam pulvinar nibh eu vulputate. Sed venenatis eros at nisl ornare sollicitudin. Duis nec est gravida, sodales orci in, blandit magna.</span>
<span>Donec semper sodales lacus vel consequat.</span>
<span>Mauris augue lectus, pretium eget dui interdum, iaculis dictum erat.</span>
<span>Pellentesque sed nulla blandit, suscipit risus eu, malesuada justo.</span>
<span>Fusce in dignissim magna. Quisque at tincidunt mauris.</span>
<span>Fusce augu.... (The code has been truncated for brevity)
<span> Vestibulum ut ultricies neque.</span>
</div>