active submenu item wider than other submenu items

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
echobrin
Forum Members
Forum Members
Posts: 54
Joined: Sat May 29, 2010 6:03 pm

active submenu item wider than other submenu items

Post by echobrin »

I'm having trouble getting correct styling for the active submenu item. I got it pretty close but now it's too wide. Click on any of the submenu items under Portfolios and you'll see what I mean: http://208.43.114.52/~chiarafo/

Looking at it with Firebug, I see it's getting a width of 100% from #menu ul ul li but I don't know why it's wider than the other subitems. Thanks for any suggestions.

Here's my stylesheet:

Code: Select all

/* Main menu settings */
#menu {
   clear:both;
   float:left;
   margin:0;
   padding:0;
   border-bottom:1px solid #000; /* black line below menu */
   width:100%;
   font-family:Arial, Helvetica, sans-serif; /* Menu font */
   font-size:16px; /* Menu text size */
   z-index:1000; /* This makes the dropdown menus appear above the page content below */
   position:relative;
}

/* Top menu items */
#menu ul {
   margin:0;
   padding:0;
   list-style:none;
   float:right;
   position:relative;
   right:50%;
}
#menu ul li  {

   float:left;
   position:relative;
   left:50%;
   top:1px;
}
#menu ul li a, .currentpage  {
   display:block;
   margin:0;
   padding:.6em .5em .4em;
   font-size:1em;
   line-height:1em;
   background:#FFF;
   text-decoration:none;
   color:#444;
   font-weight:bold;
   border-bottom:1px solid #000;
}
#menu ul li.menuactive a {
   color:#000;
   background:#FFF;
}
#menu ul li a:hover {
   background:#FFF; /* Top menu items background colour */
   color:#fff;

}
#menu ul li:hover a,
#menu ul li.hover a { /* This line is required for IE 6 and below */
   background:#FFF; /* Top menu items background colour */
   color:#000;

}

/* Submenu items */
#menu ul ul {
   display:none; /* Sub menus are hiden by default */
   position:absolute;
   top:2em;
   left:0;
   right:auto; /*resets the right:50% on the parent ul */
   width:10em; /* width of the drop-down menus */
}
#menu ul ul li {
   left:auto;  /*resets the left:50% on the parent li */
   margin:0; /* Reset the 1px margin from the top menu */
   clear:left;
   width:100%;
}

#menu ul ul li a,
#menu ul li.menuactive li a,
#menu ul li:hover ul li a,
#menu ul li.hover ul li a { /* This line is required for IE 6 and below */
   font-size:.8em;
   font-weight:normal; /* resets the bold set for the top level menu items */
   background:#eee;
   color:#444;
   line-height:1.4em; /* overwrite line-height value from top menu */
   border-bottom:1px solid #ddd; /* sub menu item horizontal lines */
}
#menu ul ul li.currentpage {
   font-size:.8em;
   font-weight:normal; /* resets the bold set for the top level menu items */
   background:#eee;
   color:#444;
   line-height:1.4em; /* overwrite line-height value from top menu */
   border-bottom:1px solid #ddd; /* sub menu item horizontal lines */
}
#menu ul ul li a:hover,
#menu ul li.menuactive ul li a:hover,
#menu ul li:hover ul li a:hover,
#menu ul li.hover ul li a:hover { /* This line is required for IE 6 and below */
   background:#FFF; /* Sub menu items background colour */
   color:#000;
}

/* Flip the last submenu so it stays within the page */
#menu ul ul.last {
   left:auto; /* reset left:0; value */
   right:0; /* Set right value instead */
}

/* Make the sub menus appear on hover */
#menu ul li:hover ul,
#menu ul li.hover ul { /* This line is required for IE 6 and below */
   display:block; /* Show the sub menus */
}
User avatar
mauri
Forum Members
Forum Members
Posts: 17
Joined: Tue Aug 12, 2008 9:21 am
Location: Italy

Re: active submenu item wider than other submenu items

Post by mauri »

Seems a problem due to the padding on the rule

#menu ul li a, .currentpage

Try adding this rule

#menu ul ul li.currentpage {
  padding-left:0;
  padding-right:0;
}

buona fortuna
echobrin
Forum Members
Forum Members
Posts: 54
Joined: Sat May 29, 2010 6:03 pm

Re: active submenu item wider than other submenu items

Post by echobrin »

Thanks, that does make the width the same... but with no left padding, now the text doesn't line up with the other submenu items. But if I put left padding back in, then the box gets too wide again.
Post Reply

Return to “Layout and Design (CSS & HTML)”