gpt4 book ai didi

css - 我的 flexbox 元素不会水平显示?

转载 作者:太空宇宙 更新时间:2023-11-03 22:44:56 25 4
gpt4 key购买 nike

一段时间以来,我一直在努力解决这个奇怪的问题。

我的 flexbox 元素不会水平显示

HTML:

<div class="subSection contact">
<div class="card">
<img class="avatar" src="img/man.png">
<p>Hello</p>
<p>IS IT ME YOUR LOOKING FOR</p>
<img class="avatar" src="img/man.png">
<p>Hello</p>
<p>IS IT ME YOUR LOOKING FOR</p>
<img class="avatar" src="img/man.png">
<p>Hello</p>
<p>IS IT ME YOUR LOOKING FOR</p>
</div>
</div>

CSS:

.contact {
display: flex;
justify-content: space-around;
align-items: center;
}

最佳答案

您只有一个 flex 父项的直接子项(flex 元素),因此只有 1 个元素可以水平显示。为了让多个东西水平显示, flex 父级需要多个直接子级。看看结构,我想这就是您想要的?

.contact {
display: flex;
justify-content: space-around;
align-items: center;
}
<div class="subSection contact">
<div class="card">
<img class="avatar" src="img/man.png">
<p>Hello</p>
<p>IS IT ME YOUR LOOKING FOR</p>
</div>
<div class="card">
<img class="avatar" src="img/man.png">
<p>Hello</p>
<p>IS IT ME YOUR LOOKING FOR</p>
</div>
<div class="card">
<img class="avatar" src="img/man.png">
<p>Hello</p>
<p>IS IT ME YOUR LOOKING FOR</p>
</div>
</div>

关于css - 我的 flexbox 元素不会水平显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42426828/

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