我想要佈置兩個垂直放置的容器,它應該以這樣一種方式填充頁面上的可用垂直空間,即頂層容器與內容垂直擴展,而底層容器佔用剩餘的垂直空間並用滾動條溢出。如何將未知高度的tvo div垂直放置在彼此頂部以填充可用頁高?
這裏是一個草圖:
我卡定義的屬性的第二容器(特別是高度)。我最好的拍攝是:
.container {
margin-top: 50px;
margin-left: 25px;
margin-bottom: 50px;
position: absolute;
height: auto;
top:0;
bottom:0;
background:#ff8;
}
.first {
position: relative;
left: 0;
top: 0;
border: 1px solid red;
}
.second {
position: relative;
left: 0;
bottom: 0;
margin-top: 10px;
overflow-y: scroll;
border: 1px solid green;
}
標記:
<div class="container">
<div class="first">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer enim mi, semper id lectus nec, tincidunt congue odio. Aliquam erat volutpat. Curabitur tellus eros, mollis malesuada imperdiet eget, congue in nisi. Donec vel nunc id libero elementum dignissim. Nulla facilisi. Mauris laoreet bibendum vestibulum. Integer odio magna, tempus eu orci quis, dignissim blandit enim. </div>
<div class="second">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</div>
</div>
然而,第二個div下方流過的容器,而不是隻向上伸展到可用的容器空間。
注意:是什麼讓問題變得非常重要,因爲兩個div的高度值都不是預先知道的,而是取決於內容! (否則,我會能夠手動設置高度,而不打擾你們:))
任何提示如何進行?
如果機頂盒內有如此多的內容可能會佔用整個容器,會發生什麼? – cimmanon
@cimmanon增加了標記,謝謝你的評論。從理論上講,機頂盒不會包含太多內容,但你確實有一點。還沒有真正考慮過它,但我想那第二個盒子根本不應該顯示。 – Krizbi