we_got_tops
10-13-2009, 10:51 AM
I have a CSS horizontal nav bar up on my site. I started by copying the code from another forum topic, and tinkered with things until it looked decent.
I'm trying to have the whole bar centered in my page. The problem is that the buttons aren't getting centered in all browsers. I can get it to look good in firefox by changing the padding (px and em) for the links. But then it doesn't look right in IE and vice versa.
I have also experimented with changing the border-width of the links, the ul border and width, and I don't have a firm grasp on what exactly these all exactly do.
Why is the navigation bar looking different in different browsers? Are there any fixes to make it display consistently? I've looked around for other forum topics, but I haven't seen one that clearly answers these questions.
I'm also pretty new to HTML/CSS, so if I'm doing anything wrong with this, please let me know.
Thanks.
#nav_bar ul{
font: bold 16px arial;
height: 30px;
width: 840px;
border: 2px ridge #000;
margin-left: auto;
margin-right: auto;
background-color: #AF3030;
}
#nav_bar ul li{
display: inline;
list-style: none;
text-align: center;
}
#nav_bar ul li a{
padding: 3px 1em;
text-decoration: none;
float: left;
color: white;
border-width: 4px;
}
#nav_bar ul li a:hover{
background-color: FFE271;
border-style: ridge;
}
<div id="nav_bar">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="main_pages/award_winners.html">Award Winners</a></li>
<li><a href="main_pages/other_stories.html">Other Stories</a></li>
<li><a href="about/faq.html">FAQ</a></li>
<li><a href="main_pages/other_content/other_content.html">Fun Features</a></li>
<li><a href="main_pages/merchandise.html">Merchandise</a></li>
</ul>
</div>
I'm trying to have the whole bar centered in my page. The problem is that the buttons aren't getting centered in all browsers. I can get it to look good in firefox by changing the padding (px and em) for the links. But then it doesn't look right in IE and vice versa.
I have also experimented with changing the border-width of the links, the ul border and width, and I don't have a firm grasp on what exactly these all exactly do.
Why is the navigation bar looking different in different browsers? Are there any fixes to make it display consistently? I've looked around for other forum topics, but I haven't seen one that clearly answers these questions.
I'm also pretty new to HTML/CSS, so if I'm doing anything wrong with this, please let me know.
Thanks.
#nav_bar ul{
font: bold 16px arial;
height: 30px;
width: 840px;
border: 2px ridge #000;
margin-left: auto;
margin-right: auto;
background-color: #AF3030;
}
#nav_bar ul li{
display: inline;
list-style: none;
text-align: center;
}
#nav_bar ul li a{
padding: 3px 1em;
text-decoration: none;
float: left;
color: white;
border-width: 4px;
}
#nav_bar ul li a:hover{
background-color: FFE271;
border-style: ridge;
}
<div id="nav_bar">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="main_pages/award_winners.html">Award Winners</a></li>
<li><a href="main_pages/other_stories.html">Other Stories</a></li>
<li><a href="about/faq.html">FAQ</a></li>
<li><a href="main_pages/other_content/other_content.html">Fun Features</a></li>
<li><a href="main_pages/merchandise.html">Merchandise</a></li>
</ul>
</div>