我一直在尝试将侧边栏垂直居中,但是我将其水平居中。我知道 display:table; 但这不是我想做的,因为我将把主要内容区域放在边栏旁边。这是代码和样式:
<div class="sidebar">
<ul>
<li>Homepage</li>
<li>blah</li>
<li>blah</li>
<li>blah</li>
<li>blah</li>
<li>blah</li>
<li>blah</li>
<li>blah</li>
</ul>
</div>
CSS:
div.sidebar{
background-color: #DEFFFF;
width: 156px;
height: 385px;
}
div.sidebar a{
color: black;
display: block;
}
div.sidebar ul li{
margin-left: -33px;
list-style-type: none;
width: 140px;
height: 25px;
border-right: 1px solid black;
border-top: 1px solid black;
border-left: 1px solid black;
background-color: #BCA264;
font-family: bold;
}