直接改list-style-type可切换ul项目符号(disc/circle/square/none),但仅对标准结构生效;若用包裹或等非列表标签,则该属性无效,需用list-unstyled类或::before伪元素实现自定义。

直接改 list-style-type 就能换圆点,但只对标准 ul 有效
Bootstrap 5 的 ul 默认用 disc(实心圆),改这个值就能切换:比如 circle 是空心圆,square 是方块。但前提是你的 HTML 结构是干净的 <ul><li>...</li></ul>。如果 li 被包在 <div class="list-group"> 里,或者用了 <code><dl></dl>,那 list-style-type 根本不生效——它只作用于原生列表容器及其直系 li。
list-style-type: none 还有圆点?先查三件事
常见原因不是属性写错了,而是样式没打中目标:
- 浏览器开发者工具里选中那个带圆点的
li,看「Styles」面板里真正起作用的规则是不是来自.list-group-item::before或类似伪元素——这种圆点靠content生成,list-style-type完全无效 - 你写的
ul { list-style-type: none; }权重可能输给 Bootstrap 的ul, ol { margin-bottom: 1rem; }(虽然它没设list-style,但某些定制版会加!important) - 用了
<dl> <dt></dt> <dd></dd> </dl>却当成列表调试,它们默认无list-style,圆点大概率来自 JS 插件或自定义背景图
比手写 CSS 更稳:优先用 Bootstrap 自带的 list-unstyled
它不只是设 list-style: none,还清了 padding-left,避免残留缩进。临时加个类就行:
- 第一项
- 第二项
如果要去圆点但想保留缩进,直接补回间距:<ul class="list-unstyled ps-4"></ul>。别用 list-inline 单独去圆点——它内部虽设了 list-style: none,但只作用于 ul 自身,某些 Safari 版本下 li 仍可能继承出圆点。
想用图标或自定义图形?别碰 list-style-image
这个属性看着方便,实际问题一堆:图片尺寸不可控、加载失败就回退成默认圆点、IE 兼容差。更可靠的做法是关掉原生符号,用 ::before 手动塞图标:
ul.custom-bullets li {
list-style: none;
position: relative;
padding-left: 24px;
}
ul.custom-bullets li::before {
content: "→";
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
color: #0d6efd;
}
关键点:必须显式写 list-style: none(不是只写 type),否则原生圆点和伪元素会叠在一起;top + transform 比固定 line-height 更适应不同字体大小。
最容易被忽略的是结构语义——很多“列表”其实不是 ul,而是 div + span 模拟的。这时候翻 CSS 文件没用,得先打开开发者工具确认真实渲染节点。圆点在哪生成,样式就得打到哪。











