Welcome to WebmasterWorld Guest from

Forum Moderators: not2easy

Message Too Old, No Replies

Help with drop down menu, vertical align and text formatting

7:08 pm on Jun 23, 2009 (gmt 0)

New User

5+ Year Member

joined:June 23, 2009
votes: 0

I'm a newb when it comes to CSS but I am eager to learn. I've done a lot of research and have gone very far without asking any questions (this is my first!). I'm just very annoyed right now because it is this same issue I always have problems with: vertically aligning text to the center of an element.

I have recently implemented a CSS-drop down menu on a site that I am building but I cannot figure out why the text is aligned to the top of the menu, instead of the center. Can somebody please take a look and help me determine where the problem is?

Also, it seems the text is pulling its formatting from html/body declarations in the CSS. I don't want these links to be the light grey color they are now. I want them all to be WHITE like the first one (Home). To make that one white I had to insert some inline CSS but I'm hoping I am just doing something wrong in the linked CSS and I can make a change there.

Here is the CSS for the dropdown:
/* style the outer div to give it width */
.menu {margin-top:5px; padding-bottom:0px; position:relative; color:#FFF; height:33px;}

/* remove all the bullets, borders and padding from the default list styling */
.menu ul {padding:0;margin:0;list-style-type:none; height:33px; background:#3a4c02; background-image:url(../images/menubar.jpg); vertical-align:middle;}

/* style the sub-level lists */
.menu ul ul {width:15em;}

/* float the top list items to make it horizontal and a relative positon so that you can control the dropdown menu positon */
.menu ul li {float:left;height:33px;line-height:33px;color:#FFF; font-size:13px;}

/* style the sub level list items */
.menu ul ul li {display:block;width:14em;height:auto;position:relative; top:-6px; border: 1px solid #ccc;border-bottom: 0;

/* style the links for the top level */
.menu a, .menu a:visited {display:block;float:left;height:100%;font-size:1em;text-decoration:none;color:#ffffff;background:none;padding:0 3em 0 1em;}

/* style the sub level links */
.menu ul ul a, .menu ul ul a:visited {display:block;background:#ffffff; color:#333;width:12em;height:100%;line-height:1em; padding:0.5em 1em;}
.menu ul table ul a, .menu ul table ul a:visited {width:13em; width:13em;}

/* style the table so that it takes no part in the layout - required for IE to work */
.menu table {position:absolute; left:0; top:0; font-size:1em; z-index:-1;}
.menu ul ul table {lef\t:-1px;}
.menu ul ul table ul.left {margin-lef\t:2px;}

.menu li:hover {position:relative;}
* html .menu a:hover {position:relative;}

/* style the third level background */
.menu ul ul ul a, .menu ul ul ul a:visited {background:#fff;}
/* style the fourth level background */
.menu ul ul ul ul a, .menu ul ul ul ul a:visited {background:#fff;}
/* style the sub level 1 background */
.menu ul :hover a.sub1 {background:#fff;}
/* style the sub level 2 background */
.menu ul ul :hover a.sub2 {background:#fff;}

/* style the level hovers */
/* first */
.menu a:hover {color:#fff;background:#7b942e;}
.menu :hover > a {color:#fff;background:#7b942e;}
/* second */
.menu ul ul a:hover{color:#000;background:#CCC;}
.menu ul ul :hover > a {color:#000;background:#ccc;}
/* third */
.menu ul ul ul a:hover {background:#ddd;}
.menu ul ul ul :hover > a {background:#ddd;}
/* fourth */
.menu ul ul ul ul a:hover {background:#eee;}

/* hide the sub levels and give them a positon absolute so that they take up no room */
.menu ul ul {visibility:hidden;position:absolute;height:0;top:3em;left:0;width:13em;}

/* position the third level flyout menu */
.menu ul ul ul{left:14em;top:0;width:13em;}

/* position the third level flyout menu for a left flyout */
.menu ul ul ul.left {left:-13em;}

/* make the second level visible when hover on first level list OR link */
.menu ul li:hover ul, .menu ul a:hover ul {visibility:visible; height:auto; padding-bottom:3em; background:transparent url(images/trans.gif);}
/* keep the third level hidden when you hover on first level list OR link */
.menu ul :hover ul ul{visibility:hidden;}
/* keep the fourth level hidden when you hover on second level list OR link */
.menu ul :hover ul :hover ul ul{visibility:hidden;}
/* make the third level visible when you hover over second level list OR link */
.menu ul :hover ul :hover ul{visibility:visible;}
/* make the fourth level visible when you hover over third level list OR link */
.menu ul :hover ul :hover ul :hover ul {visibility:visible;}

And here is the HTML:

<div class="menu">

<li><a href="../menu/index.html" style="color:#fff; vertical-align:bottom;">Home<!--[if IE 7]><!--></a><!--<![endif]-->

<li><a href="../boxes/index.html">Products<!--[if IE 7]><!--></a><!--<![endif]-->
<li><a href="spies.html" title="a coded list of spies">Wood Floor 1</a></li>
<li><a href="vertical.html" title="a horizontal vertical menu">Wood Floor 2</a></li>
<li><a href="expand.html" title="an enlarging unordered list">Wood Floor 3</a></li>
<li><a href="enlarge.html" title="an unordered list with link images">Wood Floor 4</a></li>
<li><a href="cross.html" title="non-rectangular links">Wood Floor 5</a></li>
<li><a href="jigsaw.html" title="jigsaw links">Wood Floor 6</a></li>

<li><a href="../mozilla/index.html">Photos<!--[if IE 7]><!--></a><!--<![endif]-->
<li><a href="../mozilla/dropdown.html" title="A drop down menu">Gallery 1</a></li>
<li><a href="../mozilla/cascade.html" title="A cascading menu">Gallery 2</a></li>
<li><a href="../mozilla/content.html" title="Using content:">Gallery 3</a></li>
<li><a href="../ie/index.html">Contact<!--[if IE 7]><!--></a><!--<![endif]-->

<li><a href="../opacity/index.html">Specials<!--[if IE 7]><!--></a><!--<![endif]-->



Thank you for any help you can provide!