我有兩列的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