I'm trying to increase the size of my list item markers with the following CSS:
li::marker {
color: grey;
font-size: 3.5rem;
}
<ul>
<li>Hello</li>
<li>Gromit</li>
</ul>
The resize works perfectly, but the markers are no longer aligned vertically with the list item contents.
I tried using vertical-align
, but I can't seem to get the desired result:
li {
vertical-align: middle;
}
li::marker {
color: grey;
font-size: 3.5rem;
vertical-align: middle;
}
<ul>
<li>Hello</li>
<li>Gromit</li>
</ul>
I tried using position: absolute
on the marker to move it. I also tried transform: translateY(x);
, but I can't get either to move the marker at all for some reason… Plus I would hate to have to go back and fiddle with x
every time I change the font size of the list item or marker.
Here is one of my attempts as an example:
li::marker {
color: grey;
font-size: 3.5rem;
transform: translateY(1000rem);
}
<ul>
<li>Hello</li>
<li>Gromit</li>
</ul>
I've seen a lot of similar questions, but none of them seem to provide a solution which:
- Doesn't introduce extra HTML markup
- Doesn't introduce custom values that would need to change if the font size of the list item (or that of the marker) changes.
- Doesn't require JavaScript
That being said, if I missed something, feel free to point me in the right direction and I will mark this as a duplicate myself.