如何替换点“."来自'a'类型的有序列表 [英] How to replace the dot '.' from an ordered list of type 'a'

查看:49
本文介绍了如何替换点“."来自'a'类型的有序列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上需要替换这个:

一个.元素 a
湾元素 b
C.元素 c

为此:

a:元素 a
b: 元素 b
c: 元素 c

尝试了以下(自定义计数器作为每个

  • 之前的伪元素):

      <li>元素a</li><li>元素b</li><li>元素c</li></ol>

    ol >李:之前{内容:计数器(项目):";反增量:项目;}

    但我得到了这个结果:
    a.1:元素a
    b.2:元素b
    c.3: 元素 c

    所以这似乎只适用于常规(编号)有序列表.有没有办法实现这一点,还是我必须对其进行硬编码?

    解决方案

    Following 这篇文章,你可以这样做:

    ol {列表样式类型:无;计数器重置:元素计数器;填充左:0;}李:之前{内容:步骤"计数器(元素计数器)".";计数器增量:元素计数器;字体粗细:粗体;}

    还有:

      <li>将袋子放入冰箱等...</li><li>预热烤箱</li></ol>

    I basically need to replace this:

    a. Element a
    b. Element b
    c. Element c

    To this:

    a: Element a
    b: Element b
    c: Element c

    Tried the following (custom counter as a pseudo-element before each <li>):

    <ol type="a">
      <li>Element a</li>
      <li>Element b</li>
      <li>Element c</li>
    </ol>
    

    ol > li:before {
        content: counter(item) ":";
        counter-increment: item;
    }
    

    But I get this result:
    a.1: Element a
    b.2: Element b
    c.3: Element c

    So this seems to work only on regular (numbered) ordered lists. Is there a way to achieve this or would I have to hard code it?

    解决方案

    Following this post, you can do this :

    ol {
     list-style-type: none;
     counter-reset: elementcounter;
     padding-left: 0;
    }
    
    li:before {
     content: "Step " counter(elementcounter) ". ";
     counter-increment: elementcounter;
     font-weight: bold;
    }
    

    And :

    <ol>
     <li>Place bag in freezer, etc...</li>
     <li>Preheat oven</li>
    </ol>
    

    这篇关于如何替换点“."来自'a'类型的有序列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆