我真的很难让我的水平导航栏居中。我试过混合显示:内联块;代码但无济于事,有谁知道我可以如何尝试不同的事情。
HTML 代码
<div class="container">
<div id="navcontainer" class="navlist" style="background: #99ccff;">
<ul id="navlist">
<li><a id="link1" onmouseover="chbg('#99ccff')" onMouseOut="chbg('#99ccff')" href="#">Products</a></li>
<li><a id="link2" onmouseover="chbg('#ff9999')" onMouseOut="chbg('#99ccff')" href="#">Holidays / Travel</a></li>
<li><a id="link3" onmouseover="chbg('#ffff99')" onMouseOut="chbg('#99ccff')" href="#">Motors / Transport</a></li>
<li><a id="link4" onmouseover="chbg('#99cc66')" onMouseOut="chbg('#99ccff')" href="#">Services</a></li>
</ul>
<br style="clear:right"/>
</div>
</div>
CSS 代码
.navlist {
width: 100%;
background-color: #333;
padding-top: 90px;
text-align:center;
}
.navlist ul {
margin: 0; padding: 0;
float: left;
}
.navlist ul li {
display:inline;
}
.navlist ul li a {
text-decoration: none;
color: white;
padding: 0px 20px;
display:inline-block;
}
.navlist ul li a:visited {
color: #333;
}
.navlist ul li a:hover, .menu ul li .current {
color: #333;
}