gpt4 book ai didi

css - 如何在CSS伪元素class::after中添加padding top

转载 作者:行者123 更新时间:2023-11-28 15:33:28 26 4
gpt4 key购买 nike

我想在::after 中添加 padding top 并使其居中。

但这并没有发生,这就是我得到的:

enter image description here

使用这个 css 之后:

.list-unstyled li::after {
content: url(images/heartborder.png)
text-align:center;
padding-top: 30px;
}

这是我的 HTML 代码:

<li>
<div class="col span-1-of-3 box">
<span class="icon-small">
<i class="fa fa-eye" aria-hidden="true"></i>
<div class="details">
<h5 class="heading">View / Edit Profile</h5>
<p>You can view or edit your profile from here. Phone no., address, other information etc. etc.</p>
</div>
</span>
</div>
</li>

最佳答案

您的 :after 默认设置为 display: inline 因此填充对其没有影响。将其更改为 inline-blockblock 即可。

要使其居中(按照评论中的要求),请在 div 上使用 flex,如下所示:

div {
width: 50px;
height: 50px;
background: green;
display: flex;
justify-content: center;
}

div:after {
content: "";
width: 20px;
height: 20px;
background: blue;
display: inline-block;
padding-top: 5px;
}
<div></div>

关于css - 如何在CSS伪元素class::after中添加padding top,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44409367/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com