I have an HTML list and each list item of LTR text has a hanging indent. When the user hovers over a list item, I want the background of the entire string of the list item to be hovered.
But because of the hanging indent, the entire string does not get highlighted.
Here is a minimum reproducible code example of this issue:
.test {
margin-left: 5em;
width: 5em;
text-indent: -2em;
list-style-type: none;
}
.test:hover {
background: lime;
}
<li class="test">hello world this is a test</li>
How can CSS be used to highlight the entire string on hover?
a pseudo element to cover the outside part:
Like below to cover only the first line: