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>
推荐阅读
- c# - 更改布尔变量值
- github - 如何从 API 捕获项目的最新 GitHub 版本?
- reactjs - 我如何在反应 js 中保持滚动位置和状态的同时回到历史记录
- python - python遍历树的解决方案
- javascript - 如何复制 Node.js 应用程序的当前运行时状态
- c# - Parallel Foreach array from async method
- python - 如何将结构从 python 传递给共享对象中的 ctypes 函数?
- java - 无法解决 TabLayout
- c# - 确定导航属性路径是否在 EF Core 中循环
- android - 无法启动活动 Android Studio