gpt4 book ai didi

css - 将 flex 子项对齐到顶部

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

如何让 flexbox 子元素垂直排列到每行的顶部边缘?

HTML:

#container {
align-items: flex-start;
align-content: flex-start;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.child {
margin: auto;
border: 1px dotted #CCC;
}
img, h3 {
width: 160px;
}
<div id="container">
<div class="child">
<img src="http://via.placeholder.com/160x160">
<h3>Title</h3>
</div>
<div class="child">
<img src="http://via.placeholder.com/160x160">
<h3>The quick brown fox jumps over the lazy dog</h3>
</div>
<div class="child">
<img src="http://via.placeholder.com/160x160">
<h3>Title</h3>
</div>
<div class="child">
<img src="http://via.placeholder.com/160x160">
<h3>Title</h3>
</div>
</div>

演示:https://codepen.io/anon/pen/GOBzOp

我看到的是this但我希望它看起来像 this

最佳答案

.childmargin:auto 更改为 margin: 0px auto

关于css - 将 flex 子项对齐到顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47504822/

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