html - 如何在 flex 容器中居中 ::after 伪内容?
问题描述
在代码段中,您将看到::after
带有边框设置的伪。我正在尝试在每个类的右侧添加一个边框,.details
并将该边框放在每列的中间,如下所示:
.header-profile__sub {
display: flex;
flex-wrap: wrap;
}
.header-profile__sub .details {
display: flex(column);
width: 100%;
}
.header-profile__sub .details p {
margin: 0.2rem 0;
line-height: 1.5;
color: #000a70;
}
.header-profile__sub .details p span:first-of-type::after {
content: ':';
}
@media (min-width: 768px) {
.header-profile__sub .details {
width: 33%;
flex-grow: 1;
background: white;
}
.header-profile__sub .details:not(:last-of-type) {
border-right: 5px solid green;
content: "";
}
}
<div class="header-profile__sub">
<div class="details">
<p>
<span><a href="#">Company Name</a></span>
</p>
<p>
<span>Plan</span>
<span> Professional</span>
</p>
</div>
<div class="details">
<p>
<span>Users</span>
<span>23</span>
</p>
<p>
<span>Founded</span>
<span>2017</span>
</p>
</div>
<div class="details">
<p>
<span>Favorite Features</span>
<span>Call Recording, Call Groups, App, Auto-Attendant</span>
</p>
</div>
</div>
解决方案
试试这个造型
.header-profile__sub {
display: flex;
flex-wrap: wrap;
}
.header-profile__sub .details {
display: flex(column);
width: 100%;
}
.header-profile__sub .details p {
margin: 0.2rem 0;
line-height: 1.5;
color: #000a70;
}
.header-profile__sub .details p span:first-of-type::after {
content: ':';
}
@media (min-width: 768px) {
.header-profile__sub .details {
width: 33%;
flex-grow: 1;
background: white;
}
.details {
position: relative;
}
.header-profile__sub .details:not(:last-of-type):after {
content: "";
border-right: 3px solid green;
position: absolute;
height: 100%;
top: 0;
right: 38%;
}
}
推荐阅读
- delphi - 如何使用数字键或 +/- 键的快捷键在 FMX 中创建 TMenuItem?
- android - Kotlin Log.i 和 Log.e 错误
- javascript - Join 中的 Sequelize 或条件
- angular - 仅在首次登录时显示初始用户设置组件
- python - 如何添加炒作?
- docker - 在 GKE 中拉取 docker 镜像
- sql - Postgres独特的约束性能,插入+重复或检查失败?
- c# - 使用来自 OnMouseMove 的 froms OnPaint 方法中的图形绘制时的 C# 大延迟
- python - 我做了这个 Python 脚本,它应该在一个名为 diep.io 的网络游戏中自动射击方块。它不起作用,我做错了什么?
- python - 如何在表格中添加垂直标题?