21

可能重复:
HTML + CSS:没有句点的有序列表?

想要删除点“。” 来自 OL(订单列表)

<ol>
<li>One</li>
<li>Two</li>
</ol> 

结果

 1. One
 2. Two

要求的结果

 1 One  
 2 Two
4

1 回答 1

40

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

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

甚至:

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

如果您希望也支持较旧的浏览器,那么您可以这样做(由 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 ! */
}
于 2012-08-14T05:11:57.310 回答