Issues with Drop Down Menu size and overlap CSS/HTML -
i having trouble drop down menu, second level items overlap each other , each item has different width. have searched site , tried fixes similar problems, haven found works. not programer, trying add website. here code:
#menu ul, #menu li, #menu span, #menu { margin: 0; padding: 0; position: relative; } #menu ul { list-style: none; position: absolute; top: 1.1em; } #menu { position: relative; background: #171e35 url('images/menubg.gif') repeat-x top left; height: 3.5em; padding: 0em 1.0em 0em 1.0em; margin-bottom: 10px; } #menu ul > ul > li { float: left; } #menu ul ul { display: none; position: absolute; top: 36px; left: -1px; width: 100px; text-align: left; *width: 100%; /* ie7 hack*/ } #menu li:hover ul { display: block; } #menu:after, #menu ul:after { content: ''; display: block; clear: both; } #menu ul li { position: relative; display: inline; } #menu ul li { padding: 0.5em 1.0em 0.9em 1.0em; color: #fff; text-decoration: none; } /*#menu ul li a:hover { text-decoration: none; }*/ #menu ul li a.active { background: #171e35 url('images/menuactive.gif') repeat-x top left; }
<!doctype html public "-//w3c//dtd html 4.01//en" "http://www.w3.org/tr/html4/strict.dtd"> <html> <head> <meta content="text/html; charset=iso-8859-1" http-equiv="content-type"> <title>menu</title> <!-- zenlike1.0 nodethirtythree design http://www.nodethirtythree.com --> <meta name="keywords" content=""> <meta name="description" content=""> <link rel="stylesheet" type="text/css" href="test.css"> </head> <body> <div id="menu"><!-- hint: set class of menu link below "active" make appear active --> <ul> <li><a href="#" class="active">home</a></li> <li><a href="#" class="active">department</a> <ul> <li><a href="#" class="active">patrol </a></li> <li><a href="#" class="active">investigations</a></li> <li><a href="#" class="active">records </a></li> <li><a href="#" class="active">prosecution </a></li> </ul> </li> <li><a href="#" class="active">forms</a></li> <li><a href="#" class="active">gallery</a></li> <li><a href="#" class="active">media</a></li> <li><a href="#" class="active">contact</a></li> </ul> </div> <br> </body> </html>
created class submenu
, added display:block
. allows assign width
, height
value dom objects , stops menu items overlapping. in case assigned class submenu
malfunctioning menu items avoid conflicts preexisting code.
since you're not programmer took liberty polish code , remove lines weren't doing anything. simplified
link above has same functionality code (with solution) less confusing classes. may make easier continue working on site!
to fix alignment on website, replace css ul#menu ul
with:
ul#menu ul { display: none; position: absolute; top: 28px; margin-left: 70px; width: 100px; text-align: left; }
to address submenu appearing behind content add z-index:10
#menu
Comments
Post a Comment