Skip to content

Instantly share code, notes, and snippets.

@verdipratama
Forked from jirutka/sample.png
Created October 16, 2021 22:11
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 verdipratama/207238e6a35eb648ac5d35c5f442928f to your computer and use it in GitHub Desktop.
Save verdipratama/207238e6a35eb648ac5d35c5f442928f to your computer and use it in GitHub Desktop.
Nested numbered list with correct indentation in CSS. Live example at http://jsfiddle.net/a84enL8k/.
/**
* Nested numbered list with correct indentation.
*
* Tested on Firefox 32, Chromium 37, IE 9 and Android Browser. Doesn't work on IE 7 and previous.
* Source: https://gist.github.com/jirutka/32049196ab75547b7f47
*/
ol {
list-style-type: none;
counter-reset: item;
margin: 0;
padding: 0;
}
ol > li {
display: table;
counter-increment: item;
margin-bottom: 0.6em;
}
ol > li:before {
content: counters(item, ".") ". ";
display: table-cell;
padding-right: 0.6em;
}
li ol > li {
margin: 0;
}
li ol > li:before {
content: counters(item, ".") " ";
}
/**
* Nested numbered list with correct indentation.
*
* Tested on Firefox 32, Chromium 37, IE 9 and Android Browser. Doesn't work on IE 7 and previous.
* Source: https://gist.github.com/jirutka/32049196ab75547b7f47
*/
ol {
list-style-type: none;
counter-reset: item;
margin: 0;
padding: 0;
}
ol > li {
display: table;
counter-increment: item;
margin-bottom: 0.6em;
&:before {
content: counters(item, ".") ". ";
display: table-cell;
padding-right: 0.6em;
}
}
li ol > li {
margin: 0;
&:before {
content: counters(item, ".") " ";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment