Html 如何删除点“。” 在 OL LI 中有序列表项的编号之后?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11946098/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 02:13:52  来源:igfitidea点击:

How to remove dot "." after number in ordered list items in OL LI?

htmlcss

提问by The AV

Possible Duplicate:
HTML + CSS: Ordered List without the Period?

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

Want to remove dot "." from OL (order list)

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

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

Result

结果

 1. One
 2. Two

Required Result

必填结果

 1 One  
 2 Two

回答by Moin Zaman

This will work in IE8+ and other browsers

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

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

or even:

甚至:

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

If you want older browsers to be supported as well then you could do this (courtesy neemzy):

如果您还希望支持旧版浏览器,那么您可以这样做(由 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 ! */
}