我有两列的flexbox布局。如何使用固定在flex布局中的位置?
左列固定,右列可滚动。
你怎么能这样做?
看看下面的代码:
#parent {
display: flex;
}
#left {
flex-grow: 1;
}
#left div {
position: fixed;
background: blue;
top: 0;
left: 0;
height: 100vh;
}
#right {
flex-grow: 5;
background: red;
height: 300vh;
}
<div id="parent">
<div class="child" id ="left">
<div>
ABC
</div>
</div>
<div class="child" id ="right">
DEF
</div>
</div>
如何拨弄你不正是你描述? –
@Dan Farrell - 固定div的宽度不是父母的宽度。在代码中添加了一些细节。 – jonhue
我不认为你想要什么是可能的。您必须为边栏设置宽度,或者使用JavaScript动态计算宽度。 – sol