Html ol 中的单个 li 没有编号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5999688/
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
No number for a single li in an ol
提问by Sean Powell
Is there a way to not display the number for a single li in an ol. It's not an issue if it still contributes to the count of the list (I know this might seem like a strange request).
有没有办法不显示 ol.li 中单个 li 的数字?如果它仍然有助于列表的计数,这不是问题(我知道这可能看起来像一个奇怪的请求)。
回答by BalusC
Yes, just set the CSS list-style-type
property to none
on the particular <li>
.
是的,只需将 CSSlist-style-type
属性设置none
为特定的<li>
.
E.g.
例如
<ol>
<li>one</li>
<li>two</li>
<li class="nostyle">three</li>
<li>four</li>
</ol>
with
和
li.nostyle {
list-style-type: none;
}
回答by breezy
This will hide your first ordered list number.
这将隐藏您的第一个有序列表编号。
This will look strange since your hiding your first number in the ordered list. This is one possible solution through CSS
这看起来很奇怪,因为您将第一个号码隐藏在有序列表中。这是通过 CSS 的一种可能的解决方案
ol li:first-child { list-style:none }
<ol>
<li>1</li>
<li>2</li>
<li>3</li>
</ol>
回答by asif
(Not the answer, but in case someone needs...)
If you want to hide the number (bullet) of single item lists, you can use CSS3 :only-of-type
selector.
(不是答案,但以防万一有人需要...)
如果您想隐藏单个项目列表的数量(项目符号),您可以使用 CSS3:only-of-type
选择器。
li:only-of-type { list-style-type: none; }
This way, you won't have to assign different classes to your lists. Your lists can grow and shrink as necessary.
这样,您就不必为列表分配不同的类。您的列表可以根据需要增长和缩小。
And this works for both ordered and unordered lists.
这适用于有序和无序列表。