Styling ordered list numbers


/ Published in: CSS
Save to your folder(s)



Copy this code and paste it in your HTML
  1. ol {
  2. counter-reset:li; /* Initiate a counter */
  3. padding:0; /* Remove the default left padding */
  4. list-style:none; /* Disable the normal item numbering */
  5. }
  6. ol li {
  7. position:relative; /* Create a positioning context */
  8. margin:0 0 6px 2em; /* Give each list item a left margin to make room for the numbers */
  9. padding:4px 8px;
  10. border-top:2px solid #666;
  11. background:#f6f6f6;
  12. }
  13. ol li:before {
  14. content:counter(li); /* Use the counter as content */
  15. counter-increment:li; /* Increment the counter by 1 */
  16. /* Position and style the number */
  17. position:absolute;
  18. top:-2px;
  19. left:-2em;
  20. width:2em;
  21. padding:4px 0;
  22. border-top:2px solid #666;
  23. color:#fff;
  24. background:#666;
  25. font-weight:bold;
  26. font-family:"Helvetica Neue", Arial, sans-serif;
  27. text-align:center;
  28. }

URL: http://www.456bereastreet.com/lab/styling-ordered-list-numbers/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.