繁体   English   中英

CSS 中的增量计数器用于列表:之前

[英]Increment Counter in CSS for a list with :before

我试图为 CSS 的列表增加一个计数器。但是,即使我可以看到列表编号,它们也不会增加。

在此处输入图像描述

我用过:before和 CSS property counter 这是代码:

 .services__details--content__step>ul>li:before { content: counter(counter); counter-increment: counter; color: #0052ff; background-color: #e8effe; display: inline-flex; width: 40px; height: 40px; align-items: center; justify-content: center; margin-right: 16px; border-radius: 50%; }
 <div class="services__details--content__step"> <h2 class="services__details--content__title"> Les Étapes de la Création du Site </h2> <ul> <li> Évaluation du Projet <p class="services__details--content__desc"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer. </p> </li> <li> Conception et Érgonomie UX <p class="services__details--content__desc"> Took a galley of type and scrambled it to make a type specimen book. survived not only five centuries, but also the leap into electronic remaining. </p> </li> </ul> </div>

您需要先将计数器设置为 0。 您唯一需要做的就是添加:

body {
  /* Set "counter" to 0 */
  counter-reset: counter;
}

 .services__details--content__step>ul>li:before { content: counter(counter); counter-increment: counter; color: #0052ff; background-color: #e8effe; display: inline-flex; width: 40px; height: 40px; align-items: center; justify-content: center; margin-right: 16px; border-radius: 50%; } body { /* Set "counter" to 0 */ counter-reset: counter; } ul { list-style: none; }
 <div class="services__details--content__step"> <h2 class="services__details--content__title"> Les Étapes de la Création du Site </h2> <ul> <li> Évaluation du Projet <p class="services__details--content__desc"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer. </p> </li> <li> Conception et Érgonomie UX <p class="services__details--content__desc"> Took a galley of type and scrambled it to make a type specimen book. survived not only five centuries, but also the leap into electronic remaining. </p> </li> </ul> </div>

你需要counter-reset

body {
   counter-reset: counter;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM