Log in

View Full Version : Drop down menu problem in IE8, FF



kevinmeads
04-07-2010, 07:07 PM
Hi,
I have a drop down menu that works fine in IE7 but wont center on the page in iE8 or FF.
Can anybody spot what I am doing wrong?
many thanks
Kev

Here is the CSS


/* Begin CSS Drop Down Menu */

#menuh-container
{
position: center;
top: .2em;
right: 0em;
}

#menuh
{
font-size: 12px;
font-family: arial, helvetica, sans-serif;
width:100%;
float:center;
margin:2em;
margin-top: 1em;
margin: 1px 2px 50px 0;
margin: 0;
}

#menuh a
{
text-align: center;
display:block;
border: 1px solid #fff;
white-space:nowrap;
margin:0;
padding: .3em;
}

#menuh a:link, #menuh a:visited, #menuh a:active /* menu at rest */
{
color: black;
background-color: #ffffff;
text-decoration:none;
}

#menuh a:hover /* menu on mouse-over */
{
color: black;
background-color: #cdde86;
text-decoration:none;
}

#menuh a.top_parent, #menuh a.top_parent:hover /* attaches down-arrow to all top-parents */
{
/* background-image: url(images/navdown_white.gif); */
background-position: right center;
background-repeat: no-repeat;
}

#menuh a.parent, #menuh a.parent:hover /* attaches side-arrow to all parents */
{
background-image: url(images/nav_white.gif);
background-position: right center;
background-repeat: no-repeat;
}

#menuh ul
{
list-style:none;
margin:0;
padding:0;
float:left;
width:6.6em; /* width of all menu boxes */
/* NOTE: For adjustable menu boxes you can comment out the above width rule.
However, you will have to add padding in the "#menh a" rule so that the menu boxes
will have space on either side of the text -- try it */
}

#menuh li
{
position:relative;
min-height: 1px; /* Sophie Dennis contribution for IE7 */
vertical-align: bottom; /* Sophie Dennis contribution for IE7 */
}

#menuh ul ul
{
position:absolute;
z-index:500;
top:auto;
display:none;
padding: 1em;
margin:-1em 0 0 -1em;
}

#menuh ul ul ul
{
top:0;
left:100%;
}

div#menuh li:hover
{
cursor:pointer;
z-index:100;
}

div#menuh li:hover ul ul,
div#menuh li li:hover ul ul,
div#menuh li li li:hover ul ul,
div#menuh li li li li:hover ul ul
{display:none;}

div#menuh li:hover ul,
div#menuh li li:hover ul,
div#menuh li li li:hover ul,
div#menuh li li li li:hover ul
{display:block;}

/* End CSS Drop Down Menu */

auntnini
04-07-2010, 10:10 PM
The 4 possible CSS values for POSIION property are static (default HTML flow), fixed, relative, or absolute (out of HTML flow). See http://www.w3schools.com/css/css_positioning.asp. (For HTML 4 and CSS 2 or 3 anyhow, there is no position: center.)

You can use margin right/left "auto" (with text-align: center for IE) to center a div, etc. When using UL/LI for horizontal navigation buttons, it seems impossible to center them because you float them and display: inline. I cannot put my finger on some of the proposed solutions

simcomedia
04-08-2010, 04:24 PM
This section:

#menuh-container
{
position: center;
top: .2em;
right: 0em;
}


As auntnini pointed out, there's no position: center; setting in CSS. To center that container you need to do the following:

#menuh-container
{
width: 800px; /* needs a width to determine where to put it */
margin: auto;
padding: 0;

}

top: .2em; /* this would only apply if using position: absolute; */
right: 0em; /* same with this, don't need them */

If you want some margin at the top then do this:

margin: .2em auto;

The 'auto' will do the centering left-right for you.