Can ordered list produce result that looks like 1.1, 1.2, 1.3 (instead of just 1, 2, 3, …) with css?

后端 未结 11 1065
广开言路
广开言路 2020-11-22 10:13

Can an ordered list produce results that looks like 1.1, 1.2, 1.3 (instead of just 1, 2, 3, ...) with CSS? So far, using list-style-type:decimal has produced on

11条回答
  •  情书的邮戳
    2020-11-22 10:45

    Note: Use CSS counters to create nested numbering in a modern browser. See the accepted answer. The following is for historical interest only.


    If the browser supports content and counter,

    .foo {
      counter-reset: foo;
    }
    .foo li {
      list-style-type: none;
    }
    .foo li::before {
      counter-increment: foo;
      content: "1." counter(foo) " ";
    }
    1. uno
    2. dos
    3. tres
    4. cuatro

提交回复
热议问题