[英]height 100% and overflow
我的左欄和右欄需要有一個垂直滾動條。 如何在不指定height: 100%
情況下實現滾動height: 100%
html,body{height:100%;}
.row > .sidebar-fixed {
position: relative;
top: 0;
left:auto;
width: 220px;
height: 100%;
background: #F5F5F5;
overflow-y: scroll;
}
.left {
float:left;
}
.right {
float:right;
}
.fixed-fixed {
margin: 0 240px;
}
問題是要確保我的兩個div中都需要一個滾動條,最終我必須為所有父級指定高度,這會導致其他布局出現問題。 無論如何,我們可以不使用height: 100%
值來帶動滾動條。
嘗試這個
.row > .sidebar-fixed {
position: relative;
top: 0;
left:auto;
width: 220px;
height: 120px;
background: #F5F5F5;
overflow-y: scroll;
}
並從html,body
中的{height:100%;}
刪除CSS html,body
您可以改用固定定位:
.row > .sidebar-fixed {
position: fixed;
top: 0;
bottom:0;
width: 220px;
background: #F5F5F5;
overflow-y: scroll;
}
.left {
left:0;
}
.right {
right:0;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.