gpt4 book ai didi

html - 如何让 child 成长并包裹在第一个元素下面?

转载 作者:太空宇宙 更新时间:2023-11-04 06:42:51 25 4
gpt4 key购买 nike

我有一个父级,它包含 2 个子元素,第二个包含 3 个(灰色)其他设置为自动换行的子元素,唯一的问题是第二个容器没有换行在第一个容器下面,因为它有点很难解释我已经重新创建了确切的问题,这里是 jsfiddle因为可以拖动容器以更好地理解问题。

期望的结果:

[box] [ 1 ] [ 2 ] [ 3 ]
-----------------------
[box] [ 1 ] [ 2 ]
[ 3 ]

body { background-color: #20262e }
.parent { display: flex; }
.pick { margin-right: 20px; min-width: 307px; min-height: 330px; width: 307px; height: 330px; background-color: #ffffff; display: inherit; justify-content: center; align-items: center; }

.others { display: inherit; flex-wrap: wrap; }
.others > .container { display: inherit; justify-content: center; align-items: center; background-color: #ddd; margin-bottom: 20px; min-width: 307px; min-height: 330px; width: 307px; height: 330px; margin-right: 20px; }
<div class="parent">

<div class="pick">
<h2>first box</h2>
</div>

<div class="others">
<div class="container">
<h2>...</h2>
</div>
<div class="container">
<h2>...</h2>
</div>
<div class="container">
<h2>...</h2>
</div>
</div>

</div>

最佳答案

只要您将 pick div 与 others 分开,您就无法尝试执行此操作 - 您需要将这三个 container div 与您的pick div(如下面的代码片段)。

body { background-color: #20262e }
.parent { display: flex; flex-wrap:wrap; }
.pick { margin-right: 20px; min-width: 307px; min-height: 330px; width: 307px; height: 330px; background-color: #ffffff; display: inherit; justify-content: center; align-items: center; margin-bottom: 20px; }

.parent > .others { display: inherit; justify-content: center; align-items: center; background-color: #ddd; margin-bottom: 20px; min-width: 307px; min-height: 330px; width: 307px; height: 330px; margin-right: 20px; }
<div class="parent">

<div class="pick">
<h2>first box</h2>
</div>

<div class="others">
<h2>...</h2>
</div>
<div class="others">
<h2>...</h2>
</div>
<div class="others">
<h2>...</h2>
</div>

</div>

关于html - 如何让 child 成长并包裹在第一个元素下面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53537075/

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