Reputation: 363
When the font size of the LI numbers increases the numbers leave the OL container (in pink).
Is there a way to increase the number size but keep everything inside of the pink area?
Here is an example:
ol {
background: pink;
}
li {
font-size: 50px;
}
span {
font-size: 30px;
}
<ol>
<li>
<span>car</span>
</li>
<li>
<span>plane</span>
</li>
<li>
<span>boat</span>
</li>
</ol>
Upvotes: 2
Views: 1486
Reputation: 83
Run this code
ol {
background: pink;
list-style-position: inside;
}
<ol>
<li>
<span>car</span>
</li>
<li>
<span>plane</span>
</li>
<li>
<span>boat</span>
</li>
</ol>
Upvotes: 0
Reputation: 524
if youre going to just use a fixed font-size of 50px you could simply add a padding to the OL element:
ol {
padding-left: 70px;
background: pink;
}
however, if youre going to use something cooler, you could do something like this:
ol {
list-style: none;
counter-reset: my-awesome-counter;
}
ol li {
counter-increment: my-awesome-counter;
}
ol li::before {
content: counter(my-awesome-counter) ". ";
color: red;
font-weight: bold;
}
Upvotes: 1