我创建了一个无序列表。我觉得无序列表中的项目符号很烦人,所以我想删除它们。

有可能有一个没有项目符号的列表吗?


当前回答

如果您正在开发现有主题,则该主题可能具有自定义列表样式。

因此,如果无法使用列表样式更改列表样式:none;在ul或li标签中,首先检查!重要的是,因为可能有其他风格行正在覆盖您的风格。如果重要的是修复了它,您应该找到一个更具体的选择器并清除!重要的

li {
    list-style: none !important;
}

如果不是这样的话,请检查li:before。如果包含内容,请执行以下操作:

li:before {
    display: none;
}

其他回答

如果您使用Bootstrap,它有一个“未样式”类:

删除列表项的默认列表样式和左填充(仅限直接子项)。

引导2:

<ul class="unstyled">
   <li>...</li>
</ul>

http://twitter.github.io/bootstrap/base-css.html#typography

引导3和4:

<ul class="list-unstyled">
   <li>...</li>
</ul>

引导3:http://getbootstrap.com/css/#type-列表

引导4:https://getbootstrap.com/docs/4.3/content/typography/#unstyled

引导5:https://getbootstrap.com/docs/5.0/content/typography/#unstyled

ul{list-style-type:none;}

只需将无序列表的样式设置为无。

对前面的答案进行了小的改进:如果较长的行溢出到其他屏幕行,则使其更可读:

ul, li {list-style-type: none;}

li {padding-left: 2em; text-indent: -2em;}

您需要使用列表样式:none;

<ul style="list-style: none;">
    <li>...</li>
</ul>

如果您无法使其在<ul>级别工作,则可能需要将列表样式类型:none;在<li>级别:

<ul>
    <li style="list-style-type: none;">Item 1</li>
    <li style="list-style-type: none;">Item 2</li>
</ul>

您可以创建一个CSS类来避免这种重复:

<style>
ul.no-bullets li
{
    list-style-type: none;
}
</style>

<ul class="no-bullets">
    <li>Item 1</li>
    <li>Item 2</li>
</ul>

必要时,使用!重要:

<style>
ul.no-bullets li
{
    list-style-type: none !important;
}
</style>