Customizing Ordered Lists in Firefox 3
Left-aligning List Numbers:
To left-align the numbers in an ordered list, use the following code:
li::before { display: inline-block; content: counter(item) ") "; counter-increment: item; width: 2em; margin-left: -2em; }
This code creates a pseudo-element before each list item that displays the number followed by a close parenthesis. The number is left-aligned within a fixed width of 2em, and the margin-left property ensures that it is indented from the list item.
Changing the Number Character:
To change the character after the number in an ordered list, modify the value of the content property in the li::before declaration. For example, to use a period instead of a parenthesis, use the following:
content: counter(item) ".";
CSS Solution for Alphabetic/Roman Lists:
To convert an ordered list from numbers to alphabetic or Roman characters without using the type attribute, use the counter-reset, counter-increment, and list-style-type properties:
ol { counter-reset: item; } li { counter-increment: item; list-style-type: none; } li::before { display: inline-block; content: counters(item, ".") " "; }
This code resets the item counter to start from 1, increments it for each list item, and hides the default numbers using list-style-type: none. The content property then creates a pseudo-element that displays the alphabetic or Roman character followed by a period.
The above is the detailed content of How Can I Customize Ordered Lists in Firefox 3 Using CSS?. For more information, please follow other related articles on the PHP Chinese website!