html – 如何在列表编号中为单词添加前缀

所以我一直在搜索高低,并且无法找到一个看似简单问题的答案.

我有一个这样的有序列表:

<ol>
  <li>Some text here</li>
  <li>Some more text here..</li>
  <li>Oh yeah,here's some pretty text</li>
</ol>

哪个显示

  1. Some text here
  2. Some more text here..
  3. Oh yeah,here’s some pretty text

我想要真正展示的内容

Step 1. Some text here

Step 2. Some more text here..

Step 3. Oh yeah,here’s some pretty text

问题:这是否可行,如果是这样,如何在不使用可疑解决方案的情况下进行此操作?

解决方法

你可以使用:: before(:IE8之前)和counter-reset / increment
ol {
  counter-reset: number;
}
li {
  list-style: none;
  counter-increment: number;
}
li::before {
  content: "Step " counter(number) ".";
  position: relative;
  left:-5px
}
<ol>
  <li>Some text here</li>
  <li>Some more text here..</li>
  <li>Oh yeah,here's some pretty text</li>
</ol>

相关文章

vue阻止冒泡事件 阻止点击事件的执行 &lt;div @click=&a...
尝试过使用网友说的API接口获取 找到的都是失效了 暂时就使用...
后台我拿的数据是这样的格式: [ {id:1 , parentId: 0, name:...
JAVA下载文件防重复点击,防止多次下载请求,Cookie方式快速简...
Mip是什么意思以及作用有哪些