Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sdempsey/c8ddbfeaf7f80b46b87a to your computer and use it in GitHub Desktop.
Save sdempsey/c8ddbfeaf7f80b46b87a to your computer and use it in GitHub Desktop.
Adding parenthesis to ordered lists

Adding parenthesis to ordered lists ('-' * 35) Just a quick and dirty demo for customizing ordered lists.

A Pen by Sean Dempsey on CodePen.

License.

<div class="container">
<h1>Adding parenthesis to ordered lists</h1>
<ol>
<li>Parent ol selector gets: <pre>ol {
counter-reset: list;
}</pre></li>
<li>List items get:<pre>ol li {
list-style-type: none;
position: relative;
}<pre></li>
<li>Finally use a :before pseudo selector on the list items to customize and position the output:<pre>ol li:before {
counter-increment: list;
content: counter(list,decimal) ") ";
position: absolute;
left: -20px;
}</pre></li>
</ol>
</div>
.container {
@include container;
}
ol {
counter-reset: list;
// These are the important styles
li {
list-style-type: none;
position: relative;
&:before {
counter-increment: list;
content: counter(list, decimal) ") ";
position: absolute;
left: -20px;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment