Moi*_*man 26

这将适用于IE8 +和其他浏览器

ol { 
    counter-reset: item;
    list-style-type: none;
}
li { display: block; }
li:before { 
    content: counter(item) "  "; 
    counter-increment: item 
}
Run Code Online (Sandbox Code Playgroud)

甚至:

ol li:before {
  content: counter(level1) " "; /*Instead of ". " */
  counter-increment: level1;
}
Run Code Online (Sandbox Code Playgroud)

如果你想要支持旧的浏览器那么你可以这样做(礼貌neemzy):

ol li a {
    float: right;
    margin: 8px 0px 0px -13px; /* collapses <a> and dots */
    padding-left: 10px; /* gives back some space between digit and text beginning */
    position: relative; z-index: 10; /* make the <a> appear ABOVE the dots */
    background-color: #333333; /* same background color as ol ; the dots are now invisible ! */
}
Run Code Online (Sandbox Code Playgroud)

  • 如果文本超过多行,可能会出现问题。根据 [this stackoverflow answer](http://stackoverflow.com/a/486662/1171529),我建议 [以下修正](http://jsfiddle.net/26rW4/1)。 (2认同)