You need to enable JavaScript to run this app. 如何使用CSS在li元素前添加带对勾的实心圆点标记
优惠活动
大模型
产品
解决方案
定价
更多

如何使用CSS在li元素前添加带对勾的实心圆点标记

实现方案

你可以直接用CSS的::before伪元素实现自定义标记,不需要修改原有HTML结构,代码如下:

完整CSS代码

/* 可选:清除ul默认内边距 */
.my-work {
  padding-left: 0;
}

.my-work li {
  position: relative;
  /* 给左侧自定义标记预留显示空间,可根据标记大小调整 */
  padding-left: 24px;
  margin-bottom: 10px;
  line-height: 1.4;
}

.my-work li::before {
  /* 对勾符号,也可以替换为自定义图标内容 */
  content: "✓";
  position: absolute;
  left: 0;
  top: 1px;
  /* 实心圆点尺寸 */
  width: 16px;
  height: 16px;
  border-radius: 50%;
  /* 圆点背景色,可自行修改 */
  background-color: #21a67a;
  /* 对勾颜色 */
  color: #ffffff;
  font-size: 12px;
  /* 居中显示对勾 */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

调整说明

  • 可以修改width/height调整圆点大小,修改background-color换圆点颜色
  • 如果担心Unicode对勾的字体兼容性,可以用边框绘制对勾,将对应样式替换为以下代码即可:
.my-work li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: #21a67a;
}
.my-work li::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 4px;
  width: 4px;
  height: 7px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

内容的提问来源于stack exchange,提问作者Praff

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.18 21:15:04