[英]Why isn't height 100% extend the div completely to the bottom of the page?
我希望#f8f8f8
擴展到頁面底部。 我嘗試增加height: 100%;
到.tab-content
但沒有任何反應。
有什么建議么?
html, body { width: 100%; height: 100%; margin: 0; } .tab-container { color: #fff; background: #000; } .tab-content { background: #f8f8f8; height: 100%; /* doesn't work */ }
<div class="vreditor-sdk"> <div class="building"> <div class="header"></div> <div class="i-tab"> <div class="tab-container"> </div> <div class="tab-content"> Test </div> </div> </div> </div>
將背景色屬性放在i-tab類中
.i-tab {
background-color: #f8f8f8;
}
並將其從tab-content類中刪除。
在css中,當您將高度指定為百分比時,它將采用該父高度的百分比。
給予height: 100%;
到.tab-content
意味着它需要100%
高度的.itab
而不是頁面。 因此,如果您希望您的.tab-content
覆蓋整個頁面,則.itab
需要首先覆蓋整個頁面。 在到達html
元素之前,每個直接父對象都會發生同樣的情況。
所以你的解決方法應該是
html, body, .vreditor-sdk, .building, .itab, .tab-content {
height: 100%:
}
html占據頁面高度的100%,body占據html高度的100%,與頁面高度相同,依此類推...
這是頁面高度達到.tab-content
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.