gpt4 book ai didi

html - 如何在hr标签中间留出空间?

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

JSFIDDLE: https://jsfiddle.net/vezz82tr/

HTML 代码:

<div>
Section 1...
</div>
<hr>
<div>
Section 2...
</div>

CSS 代码:

hr {
border: 0;
border-top: 4px double white;
text-align: center;
}
hr:after {
content: '\2665';
display: inline-block;
position: relative;
top: -12px;
padding: 0 10px;
background: transparent;
color: white;
font-size: 18px;
}

如您所见,hr 中间有一个图标。我想在小时的中间留出一些空间,这样线条就不会在图标上方或下方。有什么建议吗?

最佳答案

你可以用 Flexbox 来做到这一点

.line {
display: flex;
width: 100%;
align-items: center;
justify-content: center;
}

hr {
border: 0;
border-top: 4px double black;
flex: 1;
z-index: 1;
}

i:after {
font-size: 30px;
color: black;
padding: 20px;
content: '\2665';
display: inline-block;
}
<div class="line">
<hr>
<i class="heart"></i>
<hr>
</div>

关于html - 如何在hr标签中间留出空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34973527/

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