gpt4 book ai didi

html - 如何在新行上创建跨度?

转载 作者:技术小花猫 更新时间:2023-10-29 12:04:42 24 4
gpt4 key购买 nike

我在一个 div 中有多个跨度,但都在同一行。我想在新行上写下每个跨度。这是 html 代码:

.divContent {
position: absolute;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
width: 100%;
bottom: 5%;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
z-index: 2;
opacity: .8
}

.divContent span {
font-size: 0.875rem;
color: #4D575D;
margin: 0 3px;
}
<div id="content" class="divContent">
<span>Span 1</span>
<span>Span 2</span>
<span>Span 3</span>
</div>

现在这段代码的结果是:跨度 1 跨度 2 跨度 3

但是我想要

跨度 1

跨度 2

跨度 3

最佳答案

更改 direction:

.divContent {
position: absolute;
display: flex;
flex-direction: column; /*added this */
width: 100%;
bottom: 5%;
justify-content: center;
align-items:center; /*added this if you want centring*/
z-index: 2;
opacity: .8
}

.divContent span {
font-size: 0.875rem;
color: #4D575D;
margin: 0 3px
}
<div id="content" class="divContent">
<span>Span 1</span>
<span>Span 2</span>
<span>Span 3</span>
</div>

关于html - 如何在新行上创建跨度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52367104/

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