你好,我有以下代码(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%确定为什么你会这样做。我想我们需要知道你的最终目标,以了解你应该如何重组这个 –