I’m trying to strikethrough
an li element including the li marker itself. On hover I want to add a strikethrough that spans through the entire li element including the li::marker
itself.
Whenever I add strikethrough
to the <li>
element it only adds strikethrough to the content and ignores the li::marker
.
I’ve tried applying the striketrhough on the marker with the code below, but that didn’t work.
li::marker:hover {
text-decoration: line-through;
}
li:hover {
text-decoration: line-through;
}
li::marker:hover {
text-decoration: line-through;
}
<ol>
<li>Foo</li>
<li>Bar</li>
<li>Foobar</li>
</ol>
2
Answers
What I’ve provided below is a hacky, absolutely filthy solution that achieves the result by wrapping the content in a relatively positioned
<span>
, and on giving it extra leading spaces on hover while simultaneously adjusting it’s position to the left. I can’t even promise it will work consistently across platforms. It’s gross, and I pray that somebody provides a better solution and that don’t have to use this approach.You can use list-style-position. Example: