Forum Moderators: not2easy
Thanks.
A quick markup doesn't show me a problem in Firefox. Vertical list, horizontal list, display: inline, block, or inline-block; on the <li> and or <a>. I'm just not able to create the problem - at least not in quick hack attempt to do so.
<div id="nav">
<ul>
<li><a href="index.html"><span class="active2">Home</span></a></li>
<li><a href="siteplan.html">Site Plan</a></li>
<li><a href="collection.html">The Collection</a></li>
<li><a href="countryhouse.html">Country House</a></li>
<li><a href="signatureinteriors.html">Signature Interiors</a></li>
<li><a href="thestables.html">The Stables</a></li>
<li><a href="ideallocation.html">Ideal Location</a></li>
<li><a href="reviews.html">Reviews</a></li>
<li><a href="builder.html">Builder</a></li>
<li><a href="contact.html"><span class="last_nav">Lot Sales</span></a></li>
</ul>
</div>
This is the css formatting:
a:hover {
color: black;
text-decoration: underline;
padding-bottom: 10px;
padding-top: 10px;
padding-right: 10px;
padding-left: 10px;
}
#nav {
height: 30px;
padding-bottom: 0px;
background-image: url(navbar/navbar2_03.jpg);
background-repeat: repeat-x;
font-family: Arial, Helvetica, sans-serif;
width: 100%;
padding-top: 0px;
text-align: center;
white-space: nowrap;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
margin-left: 0px;
}
.last_nav {
padding-left: 0px;
padding-right: 45px;
overflow: hidden;
}
I hope that's enough.
Thanks--Diane
#nav ul {
font-family: Arial, Helvetica, sans-serif;
font-size: small;
line-height: 30px;
color: #000;
white-space: nowrap;
padding-bottom: 10px;
text-align: center;
}
#nav li {
list-style-type: none;
display: inline;
padding-top: 5px;
padding-bottom: 5px;
text-align: center;
}
1) I organized your code so that I could actually test it.
2) To centre it properly I had to add padding to the right of the last menu item. This has the sound of a hacked fix. Maybe better to get the navbar to center properly without hacking in 45px;.
3) I've set my CSS to underline when you hover over the link By default <a> is underlined. I have added the CSS to remove the underline, so that it will then 'pop up' on hover.
4) I have short-handed some of the code to tighten it up, and organized some so that it will be easier to work with in the future. For example, #nav has padding-bottom: as the second item in the declaration block and padding-top: as the seventh item in this block. It will be easier to work with your code in the future if you establish a system that keeps very similar declarations together and if you follow a general pattern or system.
5) Do you really intend the 'POP' and movement of the entire navbar on hover? The declaration of padding: 10px; to a:hover is the cause of this effect. Fine it it is what you want. Not so fine if it irritates users.
6) I have added comments to several items that may not be needed. Just something to look at.
/*?*/ I have not tested any of these comments.
7) To actually answer your question. I have commented out the 45px; hack. The <ul> has, depending upon the browser, X amount of default margin-left: and/or padding-left. (Suzy_UK or swa66 can probably tell you exactly how much in every version of every browser:)) This is causing the <ul> to shift right. The hack is pushing it back left, approximately centering the navbar.
I have removed this default, which removes the need for the 45px; hack.
#nav ul {
margin: 0;
padding: 0;
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title></title>
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css" media="screen">
html, body {
margin: 0; padding: 0;
}a {
text-decoration: none;
}a:hover {
color: #000;
text-decoration: underline;
padding: 10px;
}#nav {
width: 100%;/*?*/
height: 30px;
padding-top: 0px;
padding-bottom: 0px;
background: url(navbar/navbar2_03.jpg) repeat-x;
font-family: Arial, Helvetica, sans-serif;
text-align: center;
white-space: nowrap;/*?*/
margin: 0;
}.last_nav {
padding-left: 0px;
/*padding-right: 45px;*/
overflow: hidden;/*?*/
}#nav ul {
margin: 0;
padding: 0;
font-family: Arial, Helvetica, sans-serif;
font-size: small;
line-height: 30px;
color: #000;
white-space: nowrap;/*?*/
padding-bottom: 10px;
text-align: center;/*?*/
}#nav li {
list-style-type: none;
display: inline;
padding-top: 5px;
padding-bottom: 5px;
text-align: center;/*?*/
}
</style>
</head>
<body>
<div id="nav">
<ul>
<li><a href="index.html"><span class="active2">Home</span></a></li>
<li><a href="siteplan.html">Site Plan</a></li>
<li><a href="collection.html">The Collection</a></li>
<li><a href="countryhouse.html">Country House</a></li>
<li><a href="signatureinteriors.html">Signature Interiors</a></li>
<li><a href="thestables.html">The Stables</a></li>
<li><a href="ideallocation.html">Ideal Location</a></li>
<li><a href="reviews.html">Reviews</a></li>
<li><a href="builder.html">Builder</a></li>
<li><a href="contact.html"><span class="last_nav">Lot Sales</span></a></li>
</ul>
</div>
<!--##########
I have a navbar that is in list format. To centre it properly I had to add padding to the right of the last menu item. I've set my CSS to underline when you hover over the link. However, because this one title has padding, the underline goes to the right of the text under the padding. This doesn't happen in IE7, but is happening in Firefox and Safari. Does anyone know of a fix?
-->
</body>
</html>
<edit>Tested in FF, Opera, IE7 - not tested in Safari (though not really worried).</edit>
Thanks,
Diane
a:link {
color: black;
text-decoration: none;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 10px;
padding-right: 10px;
}
a:visited {
color:black;
text-decoration: none;
padding-top: 10px;
padding-bottom: 10px;
padding-left: 10px;
padding-right: 10px;
}
a:hover {
color: black;
text-decoration: underline;
padding-bottom: 10px;
padding-top: 10px;
padding-right: 10px;
padding-left: 10px;
}
a:active {
color: #000;
text-decoration: none;
padding-bottom: 10px;
padding-top: 10px;
padding-left: 10px;
padding-right: 10px;
}
But this is all irrelevant now! You fixed my problem. setting the margin and padding to 0 centred my navbar without the hack. Thank you!
The code you said was not necessary was me struggling to get things centred. You're very good!
Cheers, diane
The code you said was not necessary