Skip to content

Instantly share code, notes, and snippets.

@johnfmorton
Last active April 17, 2023 18:23
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 johnfmorton/b720bf5f3848a4e99791681fd1752057 to your computer and use it in GitHub Desktop.
Save johnfmorton/b720bf5f3848a4e99791681fd1752057 to your computer and use it in GitHub Desktop.
Format ordered lists in contract format. 1 > 1.1 > 1.1.a
ol {
list-style-type: none;
counter-reset: custom-counter;
}
ol li {
counter-increment: custom-counter;
}
ol li::before {
content: counter(custom-counter) ". ";
}
ol ol {
counter-reset: nested-counter;
}
ol ol li {
counter-increment: nested-counter;
}
ol ol li::before {
content: counter(custom-counter) "." counter(nested-counter) ". ";
}
ol ol ol {
counter-reset: third-level-counter;
}
ol ol ol li {
counter-increment: third-level-counter;
}
ol ol ol li::before {
content: counter(custom-counter) "." counter(nested-counter) "."
counter(third-level-counter, lower-alpha) ". ";
margin-left: 0;
}
@johnfmorton
Copy link
Author

If you are using this in a CKEditor field, add .ck.ck-content to the beginning of each style, like this:

.ck.ck-content ol {
  list-style-type: none;
  counter-reset: custom-counter;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment