如何仅使用 CSS 在没有项目符号的情况下显示 HTML 列表?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2139521/
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 01:59:04  来源:igfitidea点击:

How to make a HTML list appear without the bullets signs using CSS only?

htmlcsshtml-lists

提问by M. A. Kishawy

I have an HTML list. The browser should see the list's existence and arrange the elements accordingly, however I don't want it to show a bullet next to each element. That is, a normal list appears like this:

我有一个 HTML 列表。浏览器应该看到列表的存在并相应地排列元素,但是我不希望它在每个元素旁边显示一个项目符号。也就是说,一个普通的列表是这样的:

  • text A
  • text B
  • text C
  • 文字A
  • 文字乙
  • 文本 C

I want my list to appear like this:

我希望我的列表显示如下:

text A
text B
text C

文字 A
文字 B
文字 C

回答by Erik

ul { list-style: none; }

That gets rid of the bullet points. Now you can go ahead and assign styles to space them out like in your example, if that's what you really wanted:

这摆脱了要点。现在,您可以继续分配样式以将它们隔开,就像在您的示例中一样,如果这是您真正想要的:

li { padding: 5px 0; }

If you also don't want the list indented after removing the bullets, it will take another bit, like this:

如果您也不想在删除项目符号后缩进列表,则需要另外一点,如下所示:

ul {
   list-style: none;
   margin: 0;
   padding: 0;
}

If you dont set both margin and padding to 0, it will either look right in FF or IE, but not both

如果您不将边距和填充都设置为 0,它将在 FF 或 IE 中看起来正确,但不能同时显示两者

回答by Doug T.

Use

list-style:none;

in the style for the < ul > tag

在 <ul> 标签的样式中

回答by BalusC

Alternatively, you can also use a definition list(dl, dt, dd) without definition terms (dtelements).

或者,您也可以使用不带定义项(元素)的定义列表dl, dt, )。dddt

<dl>
    <dd>text A</dd>
    <dd>text B</dd>
    <dd>text C</dd>
</dl>

But semantically I think an unordered list (ul, li) suits your particular purpose better :) So go ahead with justa piece of good CSS as explained by Erik.

但是从语义我认为一个无序列表(ulli)适合你的特殊目的更好:)所以有继续只是一块好的CSS作为由Erik解释。

回答by Chad timothy

<ul style="list-style-type:none"></u>

By setting the style type to none the bullets will not show.

通过将样式类型设置为无,项目符号将不会显示。

回答by Grumpy

list-style-type: upper-roman;

列表样式类型:大写罗马;