我在右侧使用了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