[英]Displaying horizontal list vertically in the middle fluid layout
I have a horizontal list which I am using as my navigation bar for my website. 我有一个水平列表,用作我的网站导航栏。 I am running off a fluid layout so i work with the measurement of percentages(%) in order to adjust to the screen resolution of the user.
我正在使用一种流畅的布局,因此我要进行百分比(%)的测量,以便适应用户的屏幕分辨率。 I want to vertically align my horizontal list in the centre of the div yet it just stays at the top of the div.
我想在div的中心垂直对齐我的水平列表,但它仍然位于div的顶部。 here is my code so far:
到目前为止,这是我的代码:
CSS: CSS:
#navBar{
width: 100%;
height: 8%;
border: 1px;
border-color:black;
border-style:solid;
Background-color: white;
text-align:center;
vertical-align: middle;
font-size: 20px;
color: #B0B0B9 ;
font-family: 'myFancyFont', Times, serif;
}
#navBar2{
list-style-type:none;
margin: 0;
padding:0;
text-align:center;
}
#navBar2 li{
display: inline;
padding:0 20px 0px 20px;
}
my HTML: 我的HTML:
<div id="navBar">
<ul id ="navBar2" >
<li><a href='#'> Home</a> </li>
<li><a href='#'> Events </a></li>
<li> <a href='#'>Gallery </a></li>
<li> <a href='#'>Contact Us </a></li>
</ul>
</div>
Try float:left
on #navBar2 li
尝试
float:left
在#navBar2 li
上#navBar2 li
#navBar2 li
{
float: left;
padding:0 20px 0px 20px;
}
Floats adjust better to screen widths. 浮点可以更好地适应屏幕宽度。 Read more about floats here
在这里阅读更多关于花车的信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.