Can you style ordered list numbers?

后端 未结 2 943
滥情空心
滥情空心 2020-12-07 10:16

I\'m trying to style the numbers in a ordered list, I\'d like to add background-color, border-radius and color so they match the design I\'m working from:

2条回答
  •  甜味超标
    2020-12-07 11:10

    You can do this using CSS counters, in conjunction with the :before pseudo element:

     ol {
       list-style: none;
       counter-reset: item;
     }
     li {
       counter-increment: item;
       margin-bottom: 5px;
     }
     li:before {
       margin-right: 10px;
       content: counter(item);
       background: lightblue;
       border-radius: 100%;
       color: white;
       width: 1.2em;
       text-align: center;
       display: inline-block;
     }
    1. item
    2. item
    3. item
    4. item

提交回复
热议问题