I am using css dropdown menu for the first time.. however the dropdowns simply dont seem to work.. please help..

heres the code:

.bg {background: url(images/button4.gif);}
.menu {padding:0 0 0 32px; margin:0; list-style:none; height:40px; background:#fff url(images/button1a.gif) repeat-x; position:relative; font-family:arial, verdana, sans-serif; }
.menu li.top {display:block; float:left; position:relative;}
.menu li a.top_link {display:block; float:left; height:40px; line-height:33px; color:#bbb; text-decoration:none; font-size:11px; font-weight:bold; padding:0 0 0 12px; cursor:pointer;}
.menu li a.top_link span {float:left; font-weight:bold; display:block; padding:0 24px 0 12px; height:40px;}
.menu li a.top_link span.down {float:left; display:block; padding:0 24px 0 12px; height:40px; background:url(images/down.gif) no-repeat right top;}
.menu li a.top_link:hover {color:#000; background: url(images/button4.gif) no-repeat;}
.menu li a.top_link:hover span {background:url(images/button4.gif) no-repeat right top;}
.menu li a.top_link:hover span.down {background:url(images/button4a.gif) no-repeat right top;}

.menu li:hover > a.top_link {color:#000; background: url(images/button4.gif) no-repeat;}
.menu li:hover > a.top_link span {background:url(images/button4.gif) no-repeat right top;}
.menu li:hover > a.top_link span.down {background:url(images/button4a.gif) no-repeat right top;}

.menu table {border-collapse:collapse; width:0; height:0; position:absolute; top:0; left:0;}

.menu a:hover {visibility:visible;}
.menu li:hover {position:relative;}
.menu ul,
.menu :hover ul ul,
.menu :hover ul :hover ul ul,
.menu :hover ul :hover ul :hover ul ul,
.menu :hover ul :hover ul :hover ul :hover ul ul {position:absolute; left:-9999px; top:-9999px; width:0; height:0; margin:0; padding:0; list-style:none;}

.menu :hover ul.sub {left:2px; top:40px; right:2px; background: #fff; padding:3px 0; border:1px solid #999999; white-space:nowrap; width:200px; height:auto;}
.menu :hover ul.sub li {display:block; height:20px; position:relative; float:left; width:250px;}
.menu :hover ul.sub li a {font-weight:normal;display:block; font-size:11px; height:20px; width:192px; line-height:20px; text-indent:5px; color:#000; text-decoration:none; border:3px solid #fff; border-width:0 0 0 3px;}
.menu :hover ul.sub li a.fly {background:#fff url(images/arrow.gif) 80px 7px no-repeat;}
.menu :hover ul.sub li a:hover {background:#999999; color:#fff;}
.menu :hover ul.sub li a.fly:hover {background:#999999 url(images/arrow_over.gif) 80px 7px no-repeat; color:#fff;}
.menu :hover ul li:hover > a.fly {background:#999999 url(images/arrow_over.gif) 80px 7px no-repeat; color:#fff;}

.menu :hover ul :hover ul,
.menu :hover ul :hover ul :hover ul,
.menu :hover ul :hover ul :hover ul :hover ul,
.menu :hover ul :hover ul :hover ul :hover ul :hover ul
{left:90px; top:-4px; background: #fff; padding:3px 0; border:1px solid 999999; white-space:nowrap; width:93px; z-index:200; height:auto;}

Dani AI

Generated

A few concrete reasons the dropdowns often “don’t work” in setups like this: overly complex/incorrect selectors, small typos that invalidate declarations, submenu items floated so they line up horizontally instead of stacking, and hiding-by-offset (left:-9999px / width:0) that isn’t reliably overridden. As noted, the markup matters — mismatched or missing closing tags will break many CSS-only menus. ’s suggestion (keep hover simple) is useful as a fallback, but dropdowns need a reliable show/hide rule tied to the li that contains the submenu.

A compact, robust pattern to follow (structure: ul.menu > li > a + ul.sub) is:

.menu { list-style:none; margin:0; padding:0; }
.menu > li { position:relative; float:left; }
.menu > li > a { display:block; height:40px; line-height:40px; padding:0 12px; text-decoration:none; }
.menu li ul { display:none; position:absolute; top:100%; left:0; min-width:200px; background:#fff; border:1px solid #999; z-index:1000; }
.menu li:hover > ul { display:block; }
.menu li ul li a { display:block; padding:6px 8px; white-space:nowrap; }

Troubleshooting checklist (common, fast wins):

  • Fix typos that invalidate declarations (example seen above: border:1px solid 999999 needs a leading #). Invalid values drop that declaration.
  • Prefer display:none / display:block for show/hide or ensure the “show” rule has higher specificity and appears after the “hide” rule.
  • Remove float:left from submenu li elements so submenu items stack vertically.
  • Ensure the parent li is position:relative so the absolute submenu is positioned properly.
  • Use devtools to force :hover, inspect computed styles, and check whether another rule is overriding the intended one.
  • Remember legacy IE6: :hover on non-anchor elements isn’t supported — use a JS fallback or keep anchor-based hover for that browser.

Having the exact HTML markup (the ul/li/a structure) makes a precise diagnosis possible, as suggested.

Recommended Answers

All 2 Replies

Do you have this live somewhere? If not, also post the html, and place both in code=css and code=html tags.
This belongs in html&css, by the way, as your own title suggests.

try to use this a simple hover css properties..no drop down but it works, or just copy the basic format for the buttons. I think your css codes has no problem ..is all your "li" has already an ahref link, and open/close with the "ul".


li {
float:left;
width:150px;

}


ul {
list-style-type: none;
height: 100px;
width: 750px;
margin: auto;


}

ul a {
background-image:url(image/button2.png);
background-repeat: no-repeat;
background-position: right;
padding-right: 50px;
padding-left: 50px;
display: block;
line-height: 80px;
text-decoration: none;
font-family:Arial, Helvetica, sans-serif;
font-size: 18px;
color: #371C1C;
}

ul a:hover {
color:#FFFFFF;
background-image:url(image/button.png);
}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.