nav { width: 900px; margin: 0 auto; } nav ul { position: relative; float: left; background-color: #00FF00; list-style: none; margin: 0; padding: 0; z-index: 997; } nav ul li { display: block; padding-top: 5px; padding-left: 15px; padding-right: 15px; padding-bottom: 5px; margin-top: 4px; margin-left: 2px; margin-right: 2px; margin-bottom: 4px; border: 1px solid #000000; float: left; text-align: center; vertical-align: middle; } nav ul li:hover { background-color: #cccccc; } .submenu { background-image: url('arrow-down.jpg'); background-repeat: no-repeat; background-position: right center; background-size: 15px 15px; } nav ul li ul { display: none; } nav ul li:hover ul { display: block; position: absolute; float: none; background-color: #00FF00; list-style: none; margin: 0; padding: 0; z-index: 998; } nav ul li:hover ul li { display: block; padding-top: 5px; padding-left: 5px; padding-right: 15px; padding-bottom: 5px; margin-top: 0px; margin-left: 0px; margin-right: 0px; margin-bottom: 0px; border: 1px solid #000000; float: none; text-align: left; vertical-align: middle; } .subsubmenu { background-image: url('arrow-right.jpg'); background-repeat: no-repeat; background-position: right center; background-size: 15px 15px; } nav ul li:hover ul li ul { display: none; } nav ul li:hover ul li:hover ul { display: block; position: absolute; float: none; background-color: #00FF00; list-style: none; margin: 0; padding: 0; z-index: 999; } nav ul li:hover ul li:hover ul li { display: block; padding-top: 5px; padding-left: 5px; padding-right: 15px; padding-bottom: 5px; margin-top: 0px; margin-left: 0px; margin-right: 0px; margin-bottom: 0px; border: 1px solid #000000; float: none; text-align: left; vertical-align: middle; }
<!DOCTYPE html> <html> <head> <meta name="description" content="B44 CMS" /> <meta name="keywords" content="HTML,HTML5,CSS,CSS3,PHP,MySQL,B44,CMS" /> <meta name="author" content="Jacob Christensen" /> <meta charset="UTF-8" /> <title>B44 CMS - menu.html</title> <link rel="stylesheet" type="text/css" href="reset.css" /> <link rel="stylesheet" type="text/css" href="menu.css" /> </head> <body> <nav> <ul> <li><a href="#">[topmenu 1]</a></li> <li><a href="#">[topmenu 2]</a></li> <li class="submenu"><a href="#">[topmenu 3]</a> <ul> <li><a href="#">[submenu 3.1][submenu 3.1]</a></li> <li><a href="#">[submenu 3.2]</a></li> <li class="subsubmenu"><a href="#">[submenu 3.3]</a> <ul> <li><a href="#">[submenu 3.3.1]</a></li> <li><a href="#">[submenu 3.3.2]</a></li> <li><a href="#">[submenu 3.3.3]</a></li> <li><a href="#">[submenu 3.3.4]</a></li> <li><a href="#">[submenu 3.3.5]</a></li> </ul> </li> <li class="subsubmenu"><a href="#">[submenu 3.4]</a> <ul> <li><a href="#">[submenu 3.4.1]</a></li> <li><a href="#">[submenu 3.4.2]</a></li> <li><a href="#">[submenu 3.4.3]</a></li> <li><a href="#">[submenu 3.4.4]</a></li> <li><a href="#">[submenu 3.4.5]</a></li> </ul> </li> <li><a href="#">[submenu 3.5]</a></li> </ul> </li> <li class="submenu"><a href="#">[topmenu 4]</a> <ul> <li><a href="#">[submenu 4.1]</a></li> <li><a href="#">[submenu 4.2]</a></li> <li><a href="#">[submenu 4.3]</a></li> <li><a href="#">[submenu 4.4]</a></li> <li class="subsubmenu"><a href="#">[submenu 4.5]</a> <ul> <li><a href="#">[submenu 4.5.1]</a></li> <li><a href="#">[submenu 4.5.2]</a></li> <li><a href="#">[submenu 4.5.3]</a></li> <li><a href="#">[submenu 4.5.4]</a></li> <li><a href="#">[submenu 4.5.5]</a></li> </ul> </li> </ul> </li> <li><a href="#">[topmenu 5]</a></li> </ul> </nav> </body> </html>
nav ul li:hover ul { display: block; position: absolute; float: none; background-color: #00FF00; list-style: none; margin: 0; padding: 0; z-index: 998; }
nav ul li:hover ul { display: block; position: absolute; float: none; background-color: #00FF00; list-style: none; margin: 0; padding: 0; top: 100%; left: 0; z-index: 998; }
nav ul li:hover ul li:hover ul { display: block; position: absolute; float: none; background-color: #00FF00; list-style: none; margin: 0; padding: 0; z-index: 999; }
nav ul li:hover ul li:hover ul { display: block; position: absolute; float: none; background-color: #00FF00; list-style: none; margin: 0; padding: 0; top: 1px; left: 99%; z-index: 999; }
Meget fint, men her lære jeg jo ikke hvad det er jeg gør forkert...
nav { width: 900px; margin: 0 auto; } nav ul { position: relative; float: left; background-color: #00FF00; list-style: none; margin: 0; padding: 0; z-index: 997; line-height:1.5em; } nav ul li a { /* Tilføjet */ padding-top: 5px; /* Tilføjet */ padding-left: 15px; /* Tilføjet */ padding-right: 15px; /* Tilføjet */ padding-bottom: 5px; /* Tilføjet */ } /* Tilføjet */ nav ul li { /* display: block; */ float:left; /* Tilføjet */ position:relative; /* Tilføjet */ /* padding-top: 5px; Slettet */ /* padding-left: 15px; Slettet */ /* padding-right: 15px; Slettet */ /* padding-bottom: 5px; Slettet */ margin-top: 4px; margin-left: 2px; margin-right: 2px; margin-bottom: 4px; border: 1px solid #000000; float: left; text-align: center; vertical-align: middle; } nav ul li:hover { background-color: #cccccc; } .submenu { background-image: url('arrow-down.jpg'); background-repeat: no-repeat; background-position: right center; background-size: 15px 15px; } nav ul li ul { display: none; } nav ul li:hover ul { width: 220px; /* Tilføjet */ display: block; position: absolute; float: none; background-color: #00FF00; list-style: none; margin: 0; padding: 0; z-index: 998; } nav ul li:hover ul li a { /* Tilføjet */ padding-top: 5px; /* Tilføjet */ padding-left: 5px; /* Tilføjet */ padding-right: 15px; /* Tilføjet */ padding-bottom: 5px; /* Tilføjet */ } /* Tilføjet */ nav ul li:hover ul li { display: block; /* padding-top: 5px; Slettet */ /* padding-left: 5px; Slettet */ /* padding-right: 15px; Slettet */ /* padding-bottom: 5px; Slettet */ margin-top: 0px; margin-left: 0px; margin-right: 0px; margin-bottom: 0px; border: 1px solid #000000; float: none; text-align: left; vertical-align: middle; } .subsubmenu { background-image: url('arrow-right.jpg'); background-repeat: no-repeat; background-position: right center; background-size: 15px 15px; } nav ul li:hover ul li ul { display: none; } nav ul li:hover ul li:hover ul { display: block; position: absolute; float: none; background-color: #00FF00; list-style: none; margin: 0; padding: 0; left: 218px; /* Tilføjet */ top: 0; /* Tilføjet */ z-index: 999; } nav ul li:hover ul li:hover ul li a { /* Tilføjet */ padding-top: 5px; /* Tilføjet */ padding-left: 5px; /* Tilføjet */ padding-right: 15px; /* Tilføjet */ padding-bottom: 5px; /* Tilføjet */ } /* Tilføjet */ nav ul li:hover ul li:hover ul li { display: block; /* padding-top: 5px; Slettet */ /* padding-left: 5px; Slettet */ /* padding-right: 15px; Slettet */ /* padding-bottom: 5px; Slettet */ margin-top: 0px; margin-left: 0px; margin-right: 0px; margin-bottom: 0px; border: 1px solid #000000; float: none; text-align: left; vertical-align: middle; }
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title></title> </head> <body> <ul id="nav"> <li><a href="#">1 HTML</a></li> <li><a href="#">2 CSS</a></li> <li><a href="#">3 Javascript </a> <ul> <li><a href="#">3.1 jQuery</a> <ul> <li><a href="#">3.1.1 Download</a></li> <li><a href="#">3.1.2 Tutorial</a></li> </ul> </li> <li><a href="#">3.2 Mootools</a></li> <li><a href="#">3.3 Prototype</a></li> </ul> </li> </ul> </body> </html>
body { font-size:0.85em; font-family:Verdana, Arial, Helvetica, sans-serif; } #nav, #nav ul { margin:0; padding:0; list-style-type:none; list-style-position:outside; position:relative; line-height:1.5em; } #nav a { display:block; padding:0px 5px; border:1px solid #333; color:#fff; text-decoration:none; background-color:#333; } #nav a:hover { background-color:#fff; color:#333; } #nav li { float:left; position:relative; } #nav ul { position:absolute; display:none; width:12em; top:1.5em; } #nav li ul a { width:12em; height:auto; float:left; } #nav ul ul { top:auto; } #nav li ul ul { left:12em; margin:0px 0 0 10px; } #nav li:hover ul ul, #nav li:hover ul ul ul, #nav li:hover ul ul ul ul { display:none; } #nav li:hover ul, #nav li li:hover ul, #nav li li li:hover ul, #nav li li li li:hover ul { display:block; }