Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BronsonQuick/5544859 to your computer and use it in GitHub Desktop.
Save BronsonQuick/5544859 to your computer and use it in GitHub Desktop.
CSS to give a different color to the numbers in unordered lists
ol {
counter-reset: li; /* Initiate a counter */
margin-left: 0; /* Remove the default left margin */
padding-left: 0; /* Remove the default left padding */
}
ol > li {
position: relative; /* Create a positioning context */
margin: 0 0 0 2em; /* Give each list item a left margin to make room for the numbers */
padding: 0; /* Add some spacing around the content */
list-style: none; /* Disable the normal item numbering */
}
ol > li:before {
content: counter(li) ". "; /* Use the counter as content */
counter-increment: li; /* Increment the counter by 1 */
/* Position and style the number */
position: absolute;
top: -4px;
left: -2em;
@include box-sizing(border-box);
width: 2em;
margin-right: 8px;
padding: 4px;
color: #21a0de;
text-align: center;
font-weight: bold;
&:after {
content: ".";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment