你好,我有以下代碼(JSFiddle)如何避免一個DIV溢出另一個?
#statements {
position: relative;
top: 0;
bottom: 0;
height: 100vh;
background-color: rgba(200, 200, 200, 0.4);
max-width: 340px;
padding-left: 50px;
z-index: 1;
}
#entries {
position: relative;
height: 60%;
max-width: inherit;
overflow: scroll;
}
#entryform {
position: fixed;
height: 300px;
bottom: 0;
background-color: rgba(200, 200, 200, 0.8);
width: 340px;
}
和
<div id="statements">
<div id="entries">entry</div>
<div id="entryform">entryform</div>
</div>
我的問題是,我不能讓entries
停止前entryform
開始(也應該響應瀏覽器的高度)。
任何想法,我怎麼能讓entries
不會溢出entryform
DIV?
謝謝!
上測試'#entryform'是固定的。如果你希望'#entries'在一個固定元素之前停止,你需要進行一些js計算。 –
如果是絕對的? @KaiQing –
絕對會給你類似的效果,除了底部:0將是相對於父母,而不是視圖,因爲你已經聲明100vh#語句 - 不是100%確定爲什麼你會這樣做。我想我們需要知道你的最終目標,以瞭解你應該如何重組這個 –