Last active
December 17, 2015 03:39
-
-
Save BronsonQuick/5544859 to your computer and use it in GitHub Desktop.
CSS to give a different color to the numbers in unordered lists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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