如何删除点“。” OL LI中有序列表项中的数字后?

时间:2012-08-14 05:09:37

标签: html css

  

可能重复:
  HTML + CSS: Ordered List without the Period?

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

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

结果

 1. One
 2. Two

必填结果

 1 One  
 2 Two

1 个答案:

答案 0 :(得分:24)

这适用于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 ! */
}