我在右側使用了100vh,並且這兩個div位置都是absoulute。不確定這是構建儀表板佈局的最佳方式。我的問題是,左側邊欄似乎沒有遵循正確的內容長度。我也嘗試過100%。等高內容對齊2絕對格
#sidebar {
position: absolute;
left: 0;
width: 100px;
background: blue;
color: #fff;
height: 100vh
}
body {
margin: 0
}
li {
padding: 0;
list-style: none;
margin: 0;
}
#content {
background: #DDD;
margin-left: 100px;
width: 100%;
}
<div id="sidebar">
<li>1</li>
<li>2</li>
<li>3</li>
</div>
<div id="content">
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
<p>Content goes here</p>
</div>
https://jsbin.com/desutovosi/edit?html,css,output
呃,這是一個骯髒的黑客:( –
我是新的代碼,你能告訴我這辦法髒?謝謝:)! – GuaHsu