要在 html 中去掉 ul 和 li 标签中的点,可以采取以下步骤:使用 css 样式列表类型 none:ul, li { list-style-type: none; }。使用 before 伪元素和 content 属性:li { position: relative; padding-left: 1em; },li:before { content: “”; position: absolute; left: 0; top: 0.2em; width: 0.5em; height: 0.
如何在 HTML 中去掉 ul 和 li 标签中的点
在 HTML 中,ul(无序列表)和 li(列表项)标签通常会显示一个圆形小点作为标记。如果需要去掉这些点,可以使用 CSS 样式表。
方法:
使用列表样式类型 none:
<code class="<a style='color:#f60; text-decoration:underline;' href=" https: target="_blank">css">ul, li {
list-style-type: none;
}</code>
登录后复制
使用 before 伪元素和 content 属性:
<code class="css">li {
position: relative;
padding-left: 1em;
}
li:before {
content: "";
position: absolute;
left: 0;
top: 0.2em;
width: 0.5em;
height: 0.5em;
background-color: #000;
border-radius: 50%;
}</code>
登录后复制
使用示例:
<code class="html"><ul> <li>项目 1</li> <li>项目 2</li> <li>项目 3</li> </ul></code>
登录后复制
<code class="css">ul, li {
list-style-type: none; // 使用列表样式类型 none
}</code>
登录后复制
效果:
圆形小点将被移除,并创建带有纯文本内容的无序列表。
注意:
上面提供的解决方案只适用于 Firefox、Chrome 和 Safari 等现代浏览器。
对于 Internet Explorer 等较旧浏览器,可能需要使用额外的 hack 或 JavaScript 来实现相同的效果。






