CSS nav hover position and height

Hi

I am having bit of trouble getting the height when hovered over the same as the nav menu when not hovered over if that makes sense

The website is http://www.affordablechildrenswear.com/index.php

The html for the nav menu is below


<nav>
    <ul>
        <li><a href="">TEXT</a></li>
        <li><a href="">TEXT</a></li>
        <li><a href="">TEXT</a></li>				
        <li><a href="">TEXT</a></li>
        <li><a href="">TEXT</a></li>
        <li><a href="">TEXT</a></li>
        </ul>
        </nav>

The CSS for the nav menu is below


nav  {
display: block;
width: 950px;
overflow: hidden;
}

nav ul {
margin: 80px 0 20px 0;
padding: 0;
float: left;
list-style: none;
background: #a89ee7;
/*background: #444;
background: rgba(0,0,0,.2);*/
-moz-border-radius: .5em;
-webkit-border-radius: .5em;
border-radius: .5em;
/*-moz-box-shadow: 0 1px 0 rgba(255,255,255,.2), 0 2px 1px rgba(0,0,0,.8) inset;
-webkit-box-shadow: 0 1px 0 rgba(255,255,255,.2), 0 2px 1px rgba(0,0,0,.8) inset;
box-shadow: 0 1px 0 rgba(255,255,255,.2), 0 2px 1px rgba(0,0,0,.8) inset;*/
width: 930px;
}

nav li {
float:left;
}

nav a {
float:left;
padding: .1em 3em; /*top/right*/
text-decoration: none;
color: #555;
text-shadow: 0 1px 0 rgba(255,255,255,.5);
font: bold 1.1em/1 'trebuchet MS', Arial, Helvetica;
letter-spacing: 1px;
margin-top: 20px;
height: 30px;
text-transform: uppercase;
/*border-right: 0px;*/
/*border-width: 1px;*/
border-right: 0px solid #999;
/*border-color: #fff #ccc #999 #eee;*/
background: #a89ee7;
}

nav a:hover, nav a:focus {
outline: 0;
color: #fff;
text-shadow: 0 1px 0 rgba(0,0,0,.2);
background: #89d113;

/*background: -moz-linear-gradient(#fac754, #f8ac00);
background: -webkit-gradient(linear, left top, left bottom, from(#fac754), to(#f8ac00));
background: -webkit-linear-gradient(#fac754, #f8ac00);
background: -o-linear-gradient(#fac754, #f8ac00);
background: -ms-linear-gradient(#fac754, #f8ac00);
background: linear-gradient(#fac754, #f8ac00);*/
}

nav a:active {
-moz-box-shadow: 0 0 2px 2px rgba(0,0,0,.3) inset;
-webkit-box-shadow: 0 0 2px 2px rgba(0,0,0,.3) inset;
box-shadow: 0 0 2px 2px rgba(0,0,0,.3) inset;
}

nav li:first-child a {
border-left: 0;
-moz-border-radius: 4px 0 0 4px;
-webkit-border-radius: 4px 0 0 4px;
border-radius: 4px 0 0 4px;
}

nav li:last-child a {
border-right: 0;
-moz-border-radius: 0 4px 4px 0;
-webkit-border-radius: 0 4px 4px 0;
border-radius: 0 4px 4px 0;
}

I have tried putting in height: 30px; and line-height: 30px; to the nav a:hover but still no joy

Any ideas what else I can try or change

Kind regards

Ian

ianhaney,

I just looked at the site in Firefox and Opera and do not see any changes in font size or position when hovering. I don’t see any code that would cause any changes. Has the problem been resolved, already?

#1 on the link you gave, everything is working fine. Maybe you fixed the issue or maybe you were using that site as a ‘template’ so my comments will refer specifically to the code you posted
#2 it’s, generally speaking, a BAD IDEA to set explicit heights on elements.
#3 your problems stems from poor decisions on where to place margins ( most specifically: nav a {} and nav ul{}) note the fix bellow:


nav  {
display: block;
width: 960px;
overflow: hidden;
-moz-border-radius: .5em;
-webkit-border-radius: .5em;
border-radius: .5em;    
background: #a89ee7;
margin: 80px auto 20px auto;

}
        
nav ul {
padding: 0; 
margin:0;
float: left;
list-style: none;
}
       
nav li {
float:left;
width:160px;
}
        
nav a {
padding: 1em 3em; /*top/right*/
text-decoration: none;
display:block;
color: #555;
text-shadow: 0 1px 0 rgba(255,255,255,.5);
font: bold 1.1em/1 'trebuchet MS', Arial, Helvetica;
letter-spacing: 1px;
text-transform: uppercase;
border-right: 0px solid #999;
background: #a89ee7;            
}
         
nav a:hover, nav a:focus {
outline: 0;
color: #fff;
text-shadow: 0 1px 0 rgba(0,0,0,.2);
background: #89d113;
}
        
nav a:active {
-moz-box-shadow: 0 0 2px 2px rgba(0,0,0,.3) inset;
-webkit-box-shadow: 0 0 2px 2px rgba(0,0,0,.3) inset;
box-shadow: 0 0 2px 2px rgba(0,0,0,.3) inset;
}
        
nav li:first-child a {
border-left: 0;
-moz-border-radius: 4px 0 0 4px;
-webkit-border-radius: 4px 0 0 4px;
border-radius: 4px 0 0 4px;            
}
        
nav li:last-child a {
border-right: 0;
-moz-border-radius: 0 4px 4px 0;
-webkit-border-radius: 0 4px 4px 0;
border-radius: 0 4px 4px 0;            
}	

  • for brevity sake I am not including the code you commented out. I also assumed you goal was to create a CENTERED Hz. navigation bar with SIX BUTTONS with rounded corners at the ends.

Just a note:

padding: .1em 3em; /top/right/

Actually adds .1em padding to top AND bottom and right AND left.
padding: .1em 3em 0 0 ; /top/right/ targets top/right, but also zeros out left and bottom. so you either have to fill in the preexisting values ( in place of the zeros) or use padding-top; padding-right;

hope that helps