如何使 resize 属性 与 flexBox 一起工作?
How to make the resize property work with flexBox?
我想知道如何(如果可能的话)使用 Flexbox 和调整大小 属性。考虑以下代码:
<div style='height:300px; background:black; display:flex;flex-direction:column'>
<div style='resize:vertical; background:blue; flex-grow:1; height:100px; overflow:hidden'>
</div>
</div>
调整大小不起作用 – 我想知道如何让它起作用。
您需要删除 flex-grow
或在每次调整大小时触发增长以再次具有全高元素。使用 height:100%
代替:
<div style='height:300px; background:black; display:flex;flex-direction:column'>
<div style='resize:vertical; background:blue; ; height:100%; overflow:hidden'>
</div>
</div>
为了更好地说明这个问题,请考虑 2 个元素并查看调整大小后您将如何进行奇怪的跳跃:
.container {
height: 200px;
background: black;
display: flex;
flex-direction: column
}
.container> :first-child {
resize: vertical;
background: blue;
flex-grow:5;
height:50px;
overflow:hidden;
}
.container> :last-child {
background: red;
flex-grow:1;
}
<div class="container">
<div >
</div>
<div >
</div>
</div>
我想知道如何(如果可能的话)使用 Flexbox 和调整大小 属性。考虑以下代码:
<div style='height:300px; background:black; display:flex;flex-direction:column'>
<div style='resize:vertical; background:blue; flex-grow:1; height:100px; overflow:hidden'>
</div>
</div>
调整大小不起作用 – 我想知道如何让它起作用。
您需要删除 flex-grow
或在每次调整大小时触发增长以再次具有全高元素。使用 height:100%
代替:
<div style='height:300px; background:black; display:flex;flex-direction:column'>
<div style='resize:vertical; background:blue; ; height:100%; overflow:hidden'>
</div>
</div>
为了更好地说明这个问题,请考虑 2 个元素并查看调整大小后您将如何进行奇怪的跳跃:
.container {
height: 200px;
background: black;
display: flex;
flex-direction: column
}
.container> :first-child {
resize: vertical;
background: blue;
flex-grow:5;
height:50px;
overflow:hidden;
}
.container> :last-child {
background: red;
flex-grow:1;
}
<div class="container">
<div >
</div>
<div >
</div>
</div>