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

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


当前回答

如果您想在不使用CSS的情况下保持简单,我只需要;在我的代码行中。即<table></table>。

是的,它会留下一些空间,但这不是坏事。

其他回答

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

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

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

如果您使用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

 <div class="custom-control custom-checkbox left">
    <ul class="list-unstyled">
        <li>
         <label class="btn btn-secondary text-left" style="width:100%;text-align:left;padding:2px;">
           <input type="checkbox" style="zoom:1.7;vertical-align:bottom;" asp-for="@Model[i].IsChecked" class="custom-control-input" /> @Model[i].Title
         </label>
        </li>
     </ul>
</div>

可以使用::marker伪元素隐藏它们。

透明::标记


ul li::marker {
  color: transparent;
}

ul li::标记{颜色:透明;}上一页{填充内联开始:10px;/*只需重置浏览器初始填充*/}<ul><li>子弹很烦人</li><li>我想删除它们</li><li>嘿!::救援标志</li></ul>

::标记空内容


ul li::marker {
  content: "";
}

ul li::标记{内容:“”;}<ul><li>子弹很烦人</li><li>我想删除它们</li><li>嘿!::救援标志</li></ul>

当您需要从特定列表项中删除项目符号时,效果更好。

ul li:nth-child(n)::marker { /* Replace n with the list item's position*/
   content: "";
}

ul li:not(:第n个孩子(2))::标记{内容:“”;}<ul><li>子弹很烦人</li><li>但我可以使用::标记</li><li>但不会再这样了</li></ul>

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

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