我試着將顯示類型更改爲內嵌塊,將文本更改爲居中對齊,並將位置更改爲相對位置,但沒有任何我嘗試過的似乎可行。居中對齊水平導航欄CSS
HTML代碼:
<div id="header">
<h1>Politics and Social Media</h1>
<div id="navbar">
<ul id="menu">
<li><a href="index.html" class="button selected">Overview</a>
</li>
<li><a href="media.html" class="button">Media</a></li>
<li><a href="author.html" class="button">Author</a></li>
</ul>
</div>
<img src="images/barack.jpg" width="100%" height="75%" margin="0"
padding="0" alt="Barack Obama and Joe Biden looking at phone" >
</div><!--end of header-->
CSS代碼:
#navbar {
width: 100%;
height: 45px;
overflow: hidden;
margin: 0;
}
ul#menu {
list-style: none;
margin-left: 0;
}
ul#menu li {
float: left;
margin-left: -40px;
}