css 自定义彩色编号列表

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了css 自定义彩色编号列表相关的知识,希望对你有一定的参考价值。

/*  We first set it to zero on the OL element: */
ol { 
  list-style: none;
  counter-reset: li;
}

/*  Then, insert the content, set the color, and adjust the positioning */
li::before {
  content: counter(li);
  color: red;
  display: inline-block;
  width: 1em;
  margin-left: -1em;
}

/*  As it is our own counter, we're responsible for augmenting it as well: */
li {
  counter-increment: li;
}

/* Make some alignment tweaks  */
.example ol li::before {
  content: counter(li);
  color: red;
  display: inline-block;
  width: 1em;
  margin-left: -1.5em;
  margin-right: 0.5em;
  text-align: right;
  direction: rtl;
}

以上是关于css 自定义彩色编号列表的主要内容,如果未能解决你的问题,请参考以下文章