How to prefix a word in a list number

后端 未结 1 1967
刺人心
刺人心 2020-12-09 14:21

So I\'ve searched high and low and have been unable to find an answer for a seemingly simple problem.

I have an ordered list like this:

相关标签:
1条回答
  • 2020-12-09 15:04

    You can use ::before (:before for IE8) and 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>

    0 讨论(0)
提交回复
热议问题