html - 如何在 CSS 中创建编号标记?

我尝试编写 CSS 代码样式来生成如下所示的编号标记

但尾部圆圈的形状看起来不正确。

我在这里尝试使用 CSS 代码:

.comment-icon {
  width: 30px;
  height: 30px;
  border-radius: 100%;
  border: 2.45px solid #e7ad56;
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}

.comment-icon:before {
  position: absolute;
  content: "";
  width: 15px;
  height: 16px;
  border-top: 2.45px solid #e7ad56;
  top: 20px;
  left: -6px;
  transform: rotate(286deg);
}

.comment-icon:after {
  position: absolute;
  content: "";
  width: 15px;
  height: 16px;
  border-bottom: 2.45px solid #e7ad56;
  top: 16px;
  left: -13px;
  transform: rotate(325deg);
}
<div class="comment-icon">1</div>

我已经尝试调整 :before:after 边界定位但根本没有得到正确的点。

请问有人可以帮忙弄这个形状吗?谢谢。

最佳答案

您可以使用 :before:after 选择器来创建箭头并调整其位置。

.comment-icon {
  width: 30px;
  height: 30px;
  border-radius: 100%;
  border: 2.45px solid #e7ad56;
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}

.comment-icon:before {
  position: absolute;
  content: ""; 
  top: 24px;
  left: -9px;  
  width: 0; 
  height: 0; 
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;  
  border-top: 15px solid #e7ad56;
  transform: rotate(50deg);
}

.comment-icon:after {
  position: absolute;
  content: ""; 
  top: 24px;
  left: -5px;  
  width: 0; 
  height: 0; 
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;  
  border-top: 12px solid #fff;
  transform: rotate(50deg);
}
<div class="comment-icon">1</div>

https://stackoverflow.com/questions/68175619/

相关文章:

rust - 仅当处于 Release模式时,我如何在没有窗口的情况下运行 Rust 程序

c++ - 根据参数包值定义模板

rust - 为什么 [u8] 没有实现 Clone?

c++ - STL 中的 find() 与 binary_search()

mysql - SQL 查询问题 (MySQL)

r - 您如何使用 Pearson 相关性来选择 `R` 中的特征?

architecture - 如何在 DDD 中设计多阶段任务

python - 从列表中删除字典

sql-server - 通过 docker 创建的默认 SQL Server 凭据是什么?

cuda - Nvidia GPU 可以启动多少个线程?