CSS - Simplified Nested Horizontal Menu?
I've found a horizontal navigation menu set-up that I'd like to emulate in a simplified form but I'm having a tough time wrapping my head around what it would take.
First, here's the site with the menu system : http://rhizome.org/ In particular, I really like how there is a horizontal 'main menu' - 'Art', 'Community', and 'About' and below that a permanent horizontal bar that displays a submenu for each of the main menu items. I also really like that the submenu doesn't disappear immediately when you move the cursor away. I've examined the code but I'm having a hard time adapting and streamlining it. They don't seem to be using lists, and I would like to use lists. I've adapted menus from 'Listmatic' in the past and found them to be successful. What I'm going for is a very simple appearance with two horizontal colored bars, one above the other. The upper bar will permanently display the main menu and the lower bar will display a different submenu for each main menu item that the cursor hovers over, and the submenus won't disappear until a different main menu item is hovered over. I hope that all makes sense. Basically I'm not looking for someone to write all the code for me, but just perhaps something to get me in the right direction. Thanks in advance! Similar TutorialsI have the following list that I want displayed horizontally. I chose to do it with display:inline instead of float:left as that seemed to be the only way to get it to center on the page: http://www.jimandkris.com/listtest.html However, now I can't figure out how to get those submenus to align under their respective parent. Hopefully this is an easy one, any suggestions? Hi all, I've got a horizontal menu that is working just fine in every browser but IE 6 and 7. In IE it's almost there, except that the submenus will only appear one level deep. The menu is created with nested lists. The :hover functionality is simulated via JavaScript for IE 6. The IE developer toolbar shows the 3rd level menu is correctly being changed to display: block when its parent is hovered, and the border the dev toolbar draws even puts it in the correct place, it just doesn't actually appear. You can find the page he http://www.perceptes.com/topdog/ The CSS and JS (uses jQuery) can be found he http://www.perceptes.com/topdog/css/screen.css http://www.perceptes.com/topdog/css/ie.css (loaded with a conditional comment) http://www.perceptes.com/topdog/js/tdps.js http://www.perceptes.com/topdog/js/ie.js (loaded with a conditonal comment) For a specific example of what I'm talking about, try hovering over the second item, Filters & Parts. This will give you another level with four choices. Each of those also has child elements, but when hovered over, the next level doesn't appear. Try it in something other than IE 6 or 7 to see how it's supposed to look. Thanks very much in advance! Ok, I know virtually nothing about css, but realized that that a css menu is better for SEO. Anyway I found this vertical menu that works the way I want it. But I also need a horizontal version of it with dropdown submenus. Can someone help with this? I have been trying a bunch of things but it just looks awful and doesn't work right. It has 3 basic componets; Html, Javascript, and css. Here they are below. drop_down.js: Code: // JavaScript Document startList = function() { if (document.all&&document.getElementById) { navRoot = document.getElementById("nav"); for (i=0; i<navRoot.childNodes.length; i++) { node = navRoot.childNodes[i]; if (node.nodeName=="LI") { node.onmouseover=function() { this.className+=" over"; } node.onmouseout=function() { this.className=this.className.replace(" over", ""); } } } } } window.onload=startList; HTML: Code: <!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> <title>Horizontal Drop Down Menus</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <script type="text/javascript" src="drop_down.js"></script> <style type="text/css"> @import "style2.css"; </style> </head> <body> <ul id="nav"> <li><a href="#">Home</a></li> <li><a href="#">About</a> <ul> <li><a href="#">History</a></li> <li><a href="#">Team</a></li> <li><a href="#">Offices</a></li> </ul> </li> <li><a href="#">Services</a> <ul> <li><a href="#">Web Design</a></li> <li><a href="#">Internet Marketing</a></li> <li><a href="#">Hosting</a></li> <li><a href="#">Domain Names</a></li> <li><a href="#">Broadband</a></li> </ul> </li> <li><a href="#">Contact Us</a> <ul> <li><a href="#">United Kingdom</a></li> <li><a href="#">France</a></li> <li><a href="#">USA</a></li> <li><a href="#">Australia</a></li> </ul> </li> </ul> </body> </html> Style2.CSS: Code: body { font: normal 11px verdana; } ul { margin: 0; padding: 0; list-style: none; width: 150px; /* Width of Menu Items */ border-bottom: 1px solid #ccc; } ul li { position: relative; } li ul { position: absolute; left: 149px; /* Set 1px less than menu width */ top: 0; display: none; } /* Styles for Menu Items */ ul li a { display: block; text-decoration: none; color: #777; background: #fff; /* IE6 Bug */ padding: 5px; border: 1px solid #ccc; border-bottom: 0; } /* Fix IE. Hide from IE Mac \*/ * html ul li { float: left; height: 1%; } * html ul li a { height: 1%; } /* End */ ul li a:hover { color: #E2144A; background: #f9f9f9; } /* Hover Styles */ li ul li a { padding: 2px 5px; } /* Sub Menu Styles */ li:hover ul, li.over ul { display: block; } /* The magic */ I have read more tutorials on list than I care to recall and still I am having difficulties getting this to work right. Here is the web page The top navigation bar has a link "Other regions". I want to have a drop down list of the other regions under it. I nested a list under the "Other regions" li. It is working - sort of but not correctly. The nested list is showing up under "home" and the are all on top of each other. Here is the html: Code: <div id="topbar"> <ul> <li><a href="index.html">Home</a></li> <li><a href="about_us/about_us.html">About Us</a></li> <li class="dropmenu"><a href="other_regions.html">Other Regions</a> <ul> <li><a href="#">Ireland</a></li> <li><a href="#">Germany</a></li> <li><a href="#">USA (North America)</a></li> <li><a href="#">Latin America</a></li> <li><a href="#">Other</a></li> </ul> </li> </ul> </div> Here is the css: Code: #topbar { height: 20px; background-color: #3399FF; border: 1px solid #000099; padding-left: 10px; margin-bottom: 10px; text-align: left; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: #FFFFFF; font-size: 12px; font-weight: bold; } #topbar a:link, #topbar a:visited { color: #FFFFFF; background-color: transparent; border: 1px solid #3399FF; width: 100px; padding: 1px 2px 1px 2px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; text-decoration: none; } #topbar a:hover, #topbar a:active { color: #000099; background-color: #DDEEFF; border: 1px solid #000099; width: 100px; padding: 1px 2px 1px 2px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; text-decoration: none; } #topbar ul { list-style: none; margin: 1px 0px 1px 0px; padding: 2px 0px 0px 0px; } #topbar li { display: inline; margin-right: 150px; } .dropmenu ul { position: relative; } .dropmenu li { position: absolute; } .dropmenu a:link, .dropmenu a:visited { color: #000000; background-color: transparent; border: 1px solid #FF00FF; width: 100px; padding: 1px 2px 1px 2px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; text-decoration: none; } .dropmenu a:hover, .dropmenu a:active { color: #000099; background-color: #DDEEFF; border: 1px solid #000099; width: 100px; padding: 1px 2px 1px 2px; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold; text-decoration: none; } .dropmenu li:hover ul { display: block; } /*Main Section two columns under top section*/ #wrapper{ width: 100%; min-height: 519px; background: url(../images/bgcol.gif) repeat-y; padding: 0px; margin: 0px; } Help please I've tried the tutorials on CSS menus but can't seem to get it to work right for my project. I want a spacer to seperate the buttons at 1 pixels wide but currently it's about 10 pixels wide. I've adjusted until i'm blue in the face can somebody help? The code is below: Code: <tr> <td width="766"> <div id="navcontainer"> <ul> <li><a href="">Home</a></li> <li><a href=""> Project Status</a></li> <li><a href=""> Tasks</a></li> <li><a href="">General Information</a></li> <li><a href="">Completed Tasks</a></li> <li><a href="">About</a></li> <li><a href="">Contact</a></li> </ul> </div> CSS Code: body,html { margin: 0; } #navcontainer ul { list-style-type: none; text-align: center; font-family: Arial; font-size: 12px; font-weight: bold; color: #FFFFFF; margin: 0px; padding: 0px; } #navcontainer ul li { display: inline; } #navcontainer ul li a { text-decoration: none; padding: 0.2em 1em; color: #fff; background-image: url(images/back.gif); height: 24px; line-height: 23px; } #navcontainer ul li a:hover { color: #fff; background-color: #960033; background-attachment: fixed; background-repeat: repeat; background-position: center; background-image: url(images/backover.gif); } --- Has anyone created a CSS horizontal fly-out menu list? I have a 3 level navigation list. The level 1 has 5 items, the first item of which has no sub-list. How can I get the level 2 and 3 lists to fly-out at the same level as its parent item? I have a horizonatal menu on my webise and the list items that drop down, are all jumbled into a single block of text. How do I create a new line fore each list item? Hi, I have the following menu that is currently laid out with a table: http://www.ianarmstrong.com/menutest/ I want to switch this to be styled in CSS somehow. I've looked at using a styled unordered list to do this, but that doesn't seem like the best idea as each image in my menu is different. Thus I can't have 5 different <li> elements, each with a different bg image. I need a way to handle the 5 different images, and have a mouseover effect as well. Could someone offer some direction on this problem? I am trying to create a navigation menu for a page using images i have sliced in photoshop and I now need to put the images all on a 900px wide line and link them to the appropiate pages. When i put the images next to each other i end up with a gap. The only way I have found to solve the problem is to leave the img src all on the same line. I'm sure this isn't the best way to do it and it is throwing out the div below. Ideas anyone? Code: Code: Original - Code <div id="nav"> <img id="home" src="images/menu/home.gif" alt="" /><img id="about" src="images/menu/about.gif" alt="" /><img id="wedding" src="images/menu/wedding.gif" alt="" /><img id="corporate" src="images/menu/corporate.gif" alt="" /><img id="occasions" src="images/menu/occasions.gif" alt="" /><img id="contact" src="images/menu/contact.gif" alt="" /> </div> <div id="nav"> <img id="home" src="images/menu/home.gif" alt="" /><img id="about" src="images/menu/about.gif" alt="" /><img id="wedding" src="images/menu/wedding.gif" alt="" /><img id="corporate" src="images/menu/corporate.gif" alt="" /><img id="occasions" src="images/menu/occasions.gif" alt="" /><img id="contact" src="images/menu/contact.gif" alt="" /> </div> Jake what i want as horizontal fly out menu BUT I want the list of items to appear horizontally in a line below. These menus have the items appear vertically from a horizontal menu i looked at these and could find one http://www.cssdrive.com/index.php/menudesigns/category/C20/ Hi. Three issues with this menu - I've been trying to get a horizontal hover/nested list to work where the submenus are displayed inline underneath the main menu. 1. I've got the arrangement fairly close in FF, but in IE the top level items are jumping around all over the place on hover. 2. The javascript came from alsacreations, and seems to work pretty easily, but the submenus fail to disappear on rollOut unless you are going to another of the menu items. Any ideas? 3. Do you think there is anyway of leaving the top level links in their "active/hover" state when the mouse has moved to the submenus? So the coloured background that appears on hover stays there whilst hovering over the submenus? I've isolated the xhtml, styles and script into a page (it's a rework of a current page and is pretty incomprehensible in-situ!) at http://www.prioritypie.f2s.com/KSAV6/menuTest.html. Cheers for any advice. And I forgot to ask what the issue is with IE and transparent borders - they seem to appear black and of variable width! Problem solved, all that was required was a different li class. It's been a long while since I did anything using HTML or CSS so I might be prone to silly mistakes. A site I'm working on is giving me unusual results. The second HR is being forced to the right of the horizontal menu. No other element in it's place does the same thing. Placing another element before it makes the HR positions correctly. index.html Code: <!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> <title>Faithful 32x32</title> <meta http-equiv="Content-Type" content="text/html;charset=uft-8" /> <link rel="stylesheet" type="text/css" href="css/reset.css" media="all" /> <link rel="stylesheet" type="text/css" href="css/main.css" media="all" /> <link rel="shortcut icon" href="images/favicon.png" /> </head> <body> <div id="container"> <img src="images/logo.png" class="centered" alt="Faithful 32x32 logo"/> <h2>A double resolution texture pack that stays faithful to the original <a href="http://www.minecraft.net">Minecraft</a> textures.</h2> <hr /> <div id="centeredmenu"> <ul> <li><a href="#">Main</a></li> <li><a href="#">Download</a></li> <li><a href="#">Mod Packs</a></li> <li><a href="#">Support Us</a></li> <li><a href="#">Credits</a></li> </ul> </div> <hr /> </div> </body> </html> main.css Code: /* basic elements *********************************************************************************************/ html { height: 100%; } body { height: 100%; background-color:#8ca5ff; background-image:url('/images/darkstone.png'); font: 0.85em Cambria, Georgia, sans-serif; color:#333; } img.centered { display:block; margin:0 auto; padding-top:30px; } h2 { text-align:center; margin-top: -20px; font-size: 1.2em; } hr { height:1px; border-width:0; color:#175287; background-color:#175287; width:638px; margin:10px auto; } a { color:#3072b3; text-decoration:underline; } a:active, a:focus { outline:dotted; outline-width:1px; } /* specific divs *********************************************************************************************/ #container { background: url('/images/bg.png'); margin:0 auto; width:800px; min-height:100%; } /* top menu *********************************************************************************************/ #centeredmenu { clear:both; float:left; width:100%; position:relative; } #centeredmenu ul { list-style:none; float:right; position:relative; right:50%; } #centeredmenu ul li { float:left; position:relative; left:50%; } #centeredmenu ul li a { display:block; padding:0 .4em; font-size:1.5em; } reset.css Code: html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; outline: 0; font-weight: inherit; font-style: inherit; font-size: 100%; font-family: inherit; vertical-align: baseline; } /* remember to define focus styles! */ :focus { outline: 0; } body { line-height: 1; color: black; background: white; } ol, ul { list-style: none; } /* tables still need 'cellspacing="0"' in the markup */ table { border-collapse: separate; border-spacing: 0; } caption, th, td { text-align: left; font-weight: normal; } blockquote:before, blockquote:after, q:before, q:after { content: ""; } blockquote, q { quotes: "" ""; } Both the HTML and CSS validates. I'd post a link to the site but it's against the rules. Hopefully we can figure this out. Cheers. Hi people. In need of some help with this horizontal navigation. IE7 positions everything correctly, but when testing in firefox, chrome and safari the issues then arise. Got two images of the working styled in IE7 which is the way I was planning on having it and then the non working menu in other browsers... Live example: please click here for live example Code Code: /* Start Menu */ #topmenu { height: 32px; margin-bottom:20px; background: #FFFFFF url(menu_bg.png) repeat-x top; width: 100%; overflow: hidden; float: left; } #topmenu li { border-left: 1px solid #dedbd1; float: left; line-height: 32px; } #topmenu li a { color: #333333; display: block; margin: 0 1px 0 0; padding: 0 15px; } #topmenu li a:hover, #topmenu li.active a { color: #425775; text-decoration: none; } #nav, #nav ul { padding: 0; float:left; list-style: none; } #nav { padding: 0; } #nav a { display: block; } #nav li { float: left; line-height:32px; } #nav li a:hover { background: none; background: #FFFFFF url(menu_bgmo.png) repeat-x top; } #nav li ul { position: absolute; width: 100%; left: -999em; padding-top:1px; overflow: hidden; } #nav li:hover ul, #nav li.sfhover ul { left: auto; z-index:1000; } #nav li ul li { border-bottom:1px solid #dedbd1; border-left:1px solid #dedbd1; border-right:1px solid #dedbd1; line-height:32px; width: 100%; overflow: hidden; } #nav li:hover, #nav li.hover { position: static; } #nav li ul ul { margin: -29px 0 0 100%; overflow: hidden; } #nav li:hover ul ul, #nav li.sfhover ul ul { left: -999em; } #nav li:hover ul, #nav li li:hover ul { left: auto; } #nav li:hover ul ul, #nav li:hover ul ul ul { left: -999em; } #nav li:hover ul, #nav li li:hover ul, #nav li li li:hover ul { left: auto; overflow: hidden; } /* Finish Menu */ Any help would be great. Thanks very much in advance! terra Hi, I have a horizontal css menu that looks great in FF but doesn't align correctly in IE. Is anyone able to help me with a fix for IE browsers? HTML is Code: <!-- Begin Navigation --> <div id="navigation"> <ul class="nav"> <li><a href="default.html">HOME</a></li> <li><a href="rangemaster/about.html">ABOUT RANGEMASTER</a> <ul> <li><a href="http://www.rangemaster.co.uk/index_535.htm" target="_blank">COMPANY HISTORY</a></li> <li><a href="http://www.rangemaster.co.uk/index_65.htm" target="_blank">PRODUCTS</a></li> <li><a href="brochure.html">REQUEST BROCHURE</a></li> <li><a href="http://www.rangemaster.co.uk/ProdLocator.aspx" target="_blank">HOW TO BUY</a></li> <li><a href="rangemaster/recipes.html">GREAT RECIPE IDEAS</a></li> </ul> </li> <li><a href="falcon/about.html">ABOUT FALCON</a> <ul> <li><a href="falcon/history.html" target="_blank">COMPANY HISTORY</a></li> <li><a href="http://www.falconappliances.com/290.htm" target="_blank">PRODUCTS</a></li> <li><a href="brochure.html">REQUEST BROCHURE</a></li> <li><a href="http://www.falconappliances.com/ProdLocator.aspx" target="_blank">HOW TO BUY</a></li> <li><a href="falcon/recipes.html">GREAT RECIPE IDEAS</a></li> </ul> </li> <li><a href="aga/about.html">ABOUT AGA</a> <ul> <li><a href="http://www.aga-web.co.uk/92_243.htm" target="_blank">COMPANY HISTORY</a></li> <li><a href="http://www.aga-web.co.uk/89.htm" target="_blank">PRODUCTS</a></li> <li><a href="brochure.html">REQUEST BROCHURE</a></li> <li><a href="http://www.aga-web.co.uk/90_253.htm" target="_blank">HOW TO BUY</a></li> <li><a href="aga/recipes.html">GREAT RECIPE IDEAS</a></li> </ul> </li> <li><a href="rayburn/about.html">ABOUT RAYBURN</a> <ul> <li><a href="http://www.rayburn-web.co.uk/50.htm" target="_blank">COMPANY HISTORY</a></li> <li><a href="http://www.rayburn-web.co.uk/44.htm" target="_blank">PRODUCTS</a></li> <li><a href="brochure.html">REQUEST BROCHURE</a></li> <li><a href="http://www.rayburn-web.co.uk/48.htm" target="_blank">HOW TO BUY</a></li> <li><a href="rayburn/recipes.html">GREAT RECIPE IDEAS</a></li> </ul> </li> <li><a href="survey.html">FIND YOUR PERFECT COOKER</a> <li><a href="gallery.html">PHOTO GALLERY</a> <li><a href="brochure.html">BROCHURE REQUEST</a> </ul> </div> <!-- End Navigation --> and CSS is Code: ul.nav, .nav ul{ margin: 0; padding: 0; list-style-type: none; display: inline; font-family: Arial, Helvetica, sans-serif; font-weight: bold; font-size: 10px; height: 25px; width: 835px; } ul.nav{ display: table; background: url(../_images/menu.gif); } ul.nav>li{ display: table-cell; position: relative; padding: 6px 6px; color: #FFFFFF; text-align:left; } ul.nav li>ul{ display: none; position: absolute; width: 150px; margin-left: -10px; margin-top: 6px; } ul.nav li:hover>ul{ display : block; } .nav ul li a { display: block; padding: 2px 10px; color: #FFFFFF; } .nav a{ text-decoration: none; color: #FFFFFF; } .nav ul li a{ background-color: #000000; filter:alpha(opacity=80); opacity: 0.8; -moz-opacity:0.8; } .nav ul li a:hover { background-color: #B3191E; } .nav ul li a:active { background-color: #B3191E; } Many thanks... Hi, I have a horizontal menu, now what I would like to know how to do, is that once one of the element has focus, I would have another row underneath it that would have my links link1 | link2 | link3, etc... here is my menu bar, any info, or ideas would be great <html> <head> <style type="text/css"> .navh LI { DISPLAY: inline; LIST-STYLE-TYPE: none } .navh UL { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px; WHITE-SPACE: nowrap } .navh A { border:1px solid #333333; PADDING-RIGHT: 8px; PADDING-LEFT: 24px; PADDING-BOTTOM: 1px; PADDING-TOP: 1px; BACKGROUND-COLOR: #999999 } .navh A:link { COLOR: #eeeeee; TEXT-DECORATION: none } .navh A:visited { COLOR: #eeeeee; TEXT-DECORATION: none } .navh A:hover { border:1px solid #333333; COLOR: #333333; BACKGROUND-COLOR: #ff6600 } </style> </head> <body> <div class="navh"> <ul> <li><a href="#" >Item 1</a></li> <li><a href="#" >Item 2</a></li> <li><a href="#" >Item 3</a></li> </ul> </div> </body> </html> |