The list items may contain a couple of paragraphs, images, etc. They should all stay to the right of the item number.
#page {
width: 200px;
}
li {
margin: 1em 0;
}
ol {
padding: 0;
}
<div id="page">
<p>Some text</p>
<ol>
<li>A list item</li>
<li>A multiline list item another line</li>
<li>
<p>A list item containing blocks such as example images:</p>
<div style="width:128px;height:48px;background:#CCC">Example<br/>Image</div>
</li>
</ol>
<p>Some more text</p>
</div>
Ideally I would prefer to keep the list tags rather than use a table or other set of positioned generic blocks.
You can use list-style: inside; to align the numbers.
To center align an unordered list, you need to use the CSS text align property. In addition to this, you also need to put the unordered list inside the div element. Now, add the style to the div class and use the text-align property with center as its value. See the below example.
check out list-style-position
property
#page {
width: 200px;
}
li {
margin: 1em 0;
/* this is what you want ↓ */
list-style-position: inside;
}
ol {
padding: 0;
}
<div id="page">
<p>Some text</p>
<ol>
<li>A list item</li>
<li>A multiline list item another line</li>
</ol>
<p>Some more text</p>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With