css下边框中间有个点怎么做

admin 轻心小站 关注 LV.19 运营
发表于前端技术学习版块 css,教程

如果您想在CSS下边框中间添加一个点,可以使用以下代码进行实现:border-bottom: 1px solid #000; position: relative; 使用“position: rela

如果您想在CSS下边框中间添加一个点,可以使用以下代码进行实现:

border-bottom: 1px solid #000;
position: relative; 

使用“position: relative;”是为了让下边框上方的点相对于下边框进行定位:

border-bottom: 1px solid #000;
position: relative;

&:after {
  content: "";
  width: 6px;
  height: 6px;
  background: #000;
  position: absolute;
  bottom: -3px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 50%;
} 

在上面的代码中,“&:after”表示在下边框后面添加伪元素。在伪元素中,使用“position: absolute;”将点相对于下边框进行定位,并且“bottom: -3px;”将它定位在下边框的中心。

“left: 50%;”将点水平居中,而“transform: translateX(-50%);”则将点沿着水平方向向左移动半个点的宽度,从而让点垂直居中。

最后,“border-radius: 50%;”将点变成圆形。

文章说明:

本文原创发布于探乎站长论坛,未经许可,禁止转载。

题图来自Unsplash,基于CC0协议

该文观点仅代表作者本人,探乎站长论坛平台仅提供信息存储空间服务。

评论列表 评论
发布评论

评论: css下边框中间有个点怎么做

粉丝

0

关注

0

收藏

0

已有0次打赏