【发布时间】:2019-08-08 18:52:05
【问题描述】:
我希望display: flex; 的其中一个孩子将高度调整为其他孩子。如果这个孩子的内容比其他孩子的大,那么overflow: scroll;应该对这个内容做。
换句话说:
我希望以下代码中的中间 div(黄色背景)将其高度调整为其他 div 的高度,溢出为.tabl。
我知道这个问题和许多其他问题一样。我已经阅读了很多线程,但我仍然没有设法解决问题。我为这个帖子道歉,但我没有力气解决它。
.parent {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: baseline;
}
.child1 {
background-color: red;
align-self: stretch;
width: 25%;
min-width: 25%;
max-width: 25%;
}
.child2 {
background-color: yellow;
min-height: 0;
min-width: 0;
overflow: auto;
margin: 0 15px;
width: calc(50% - 30px);
max-width: calc(50% - 30px);
display: flex;
flex-direction: column;
flex-shrink: 1;
}
.child3 {
background-color: green;
width: 25%;
min-width: 25%;
max-width: 25%;
}
.child2 .tabl {
flex-shrink: 1;
min-height: 0;
overflow: scroll;
}
<div class="parent">
<div class="child1">
<p>Some element one</p>
<p>Some element two</p>
<p>Some element three</p>
<p>Some element four</p>
</div>
<div class="child2">
<div class="info">
<h2>Element</h2>
</div>
<div class="tabl">
<p>Some element one</p>
<p>Some element two</p>
<p>Some element three</p>
<p>Some element four</p>
<p>Some element one</p>
<p>Some element two</p>
<p>Some element three</p>
<p>Some element four</p>
<p>Some element one</p>
<p>Some element two</p>
<p>Some element three</p>
<p>Some element four</p>
<p>Some element one</p>
<p>Some element two</p>
<p>Some element three</p>
<p>Some element four</p>
</div>
<div class="footer">
<button class="btn">Some button</button>
</div>
</div>
<div class="child3">
<p>Some element one</p>
<p>Some element two</p>
<p>Some element three</p>
<p>Some element four</p>
<p>Some element one</p>
<p>Some element two</p>
<p>Some element three</p>
<p>Some element four</p>
</div>
</div>
【问题讨论】:
-
这可能会对你有所帮助:stackoverflow.com/q/48943233/8620333
标签: html css flexbox alignment