gpt4 book ai didi

html - 对齐不同父容器的子元素

转载 作者:搜寻专家 更新时间:2023-10-31 19:30:49 25 4
gpt4 key购买 nike

<分区>

我正在尝试跨容器垂直对齐可变高度元素,即每个容器中的第一个元素彼此垂直对齐,每个容器中的第二个元素彼此垂直对齐,等等。

我正在使用 flexbox 但不确定这是否可行?还是可以使用 CSS Grid?

期望的结果

enter image description here

See demo我还没有设法让它工作的地方。

main {
display: flex;
flex-wrap: wrap;
}

.container {
background: grey;
margin: 0 10px 20px;
padding: 10px;
width: 200px;
}

.top {
background: red;
}

.middle {
background: blue;
}

.bottom {
background: green;
}
<main>
<div class="container">
<div class="top">Some text here, Some text here, Some text here</div>
<div class="middle">And some here, And some here, And some here, And some here, And some here, And some here</div>
<div class="bottom">And a little here too</div>
</div>
<div class="container">
<div class="top">Some text here, Some text here</div>
<div class="middle">And some here, And some here, And some here, And some here, And some here, And some here, And some here, And some here, And some here</div>
<div class="bottom">And a little here too, And a little here too</div>
</div>
<div class="container">
<div class="top">Some text here, Some text here, Some text here, Some text here, Some text here</div>
<div class="middle">And some here</div>
<div class="bottom">And a little here too</div>
</div>
<div class="container">
<div class="top">Some text here, Some text here, Some text here</div>
<div class="middle">And some here, And some here, And some here, And some here, And some here, And some here</div>
<div class="bottom">And a little here too</div>
</div>
<div class="container">
<div class="top">Some text here, Some text here, Some text here</div>
<div class="middle">And some here, And some here, And some here, And some here, And some here, And some here</div>
<div class="bottom">And a little here too</div>
</div>
<div class="container">
<div class="top">Some text here, Some text here, Some text here</div>
<div class="middle">And some here, And some here, And some here, And some here, And some here, And some here</div>
<div class="bottom">And a little here too</div>
</div>
<div class="container">
<div class="top">Some text here, Some text here, Some text here</div>
<div class="middle">And some here, And some here, And some here, And some here, And some here, And some here</div>
<div class="bottom">And a little here too</div>
</div>
</main>

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