Advanced Search Usage Terms Submit Contact
Dynamic Drive CSS Library
 
CSS Library
Submit an original CSS code
CSS Layouts
Web Graphics
Online Tools:

Advertise Here

CSS Library: Horizontal CSS Menus: Here

SuckerTree Horizontal Menu

Author: Dynamic Drive

SuckerTree Horizontal Menu is a CSS and DOM hybrid menu that's list based and supports multiple levels of sub menus. The trick to SuckerTree is a small adoptable piece of JavaScript that crawls the inner levels of a list menu and assigns the appropriate show/hide and positioning behavior to them. You can even have multiple SuckerTree menus on the same page.

See also: SuckerTree Vertical Menu.

Demo:

The two bullet images used:

The CSS:

The HTML:

Code Info

Rate this code:

Date Posted: 09/14/2006

Revision History: None

Usage Terms: Click here

Your Comments (298)

Got a question or need help customizing this CSS code? Post it in the CSS Forums. If you have a comment or suggestion instead, post it in the comments section below.

Comment Pages 23 of 30 pages « First  <  21 22 23 24 25 >  Last »

Great script!! THanks to the creators.

Here is the fix I came up with for IE7 submenu disappearence. A little change to the javascript:

Change the .offsetWidth by -20. You may need to play with the offset if necessary, but this will fix all the submenus.

}
else{ //else if this is a sub level menu (ul)
ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth-20+"px" //position menu to the right of menu item that activated it
ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon"
}


HOPE THIS HELPS!!!
Posted by cipher7 on 01/21, 10:02 PM
I am having problems with this on Firefox 2.0.0.11. It doesn't behave well when there are multiple ul li ul li. I installed/de-installed the Holly Hack with no luck. Any ideas?
Posted by sbrown on 01/29, 07:25 AM
When I try to go down the menu in IE sometimes, the drop down menu disappears.
Posted by Artep on 02/18, 06:54 AM
This fixed my IE7 submenu disappearence:

Just give set a background to the link items in the submenu's:

/* Sub level menu links style */
.suckertreemenu ul li ul li a{
background-color: #FFFFFF;
}
Posted by BeenZ on 02/20, 04:01 AM
For screenreaders, to be able to read menu that 'hidden' hides of:


/*1st sub level menu*/
.suckertreemenu ul li ul
{
position: absolute;
top: 1em; /* no need to change, as true value set by script */
display: block;
left: -999em; /* using left instead of display to hide menus because display: none isn't read by screen readers */
width: 145px;
padding: 2em 0 0 0;
margin:0;
white-space:normal;
}




And then in script:

function buildsubmenus_horizontal(){
for (var i=0; i<menuids.length; i++){
var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
for (var t=0; t<ultags.length; t++){
if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
ultags[t].style.top=ultags[t].parentNode.offsetHeight+"px" //dynamically position first level submenus to be height of main menu item
ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon"
}
else{ //else if this is a sub level menu (ul)
ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon"
}
ultags[t].parentNode.onmouseover=function()
{
//this.getElementsByTagName("ul")[0].style.visibility="visible"
this.getElementsByTagName("ul")[0].style.left="0em"
}
ultags[t].parentNode.onmouseout=function()
{
//this.getElementsByTagName("ul")[0].style.visibility="hidden"
this.getElementsByTagName("ul")[0].style.left="-999em"
}
}
}
}
Posted by Eugene on 02/25, 01:47 PM
The above code is great! But I'm having problems showing the other tabs submenus when I hover or click on the tabs. Any feedback is greatly appreciated.
Posted by mary on 02/26, 02:26 PM
Hey jchalos, I spent almost a day trying to find a fix for the gaps between the sub-sub menus (u know wat I eman:) Thanks buddy.
Posted by amit on 03/06, 01:29 AM
please help.... I am trying to make this dropdown menu overlapping my frame below, but am a novice and lost as to how to accomplish this...

This is my frameset code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Le Diamant</title>
</head>

<frameset rows="276,*" cols="*" framespacing="0" frameborder="NO" border="0">
<frame src="menu.html" name="topFrame" scrolling="NO" noresize >
<frame src="news.html" name="mainFrame">
</frameset>
<noframes><body>
</body></noframes>
</html>
Posted by TeeQ on 03/06, 02:15 PM
<html>
<head>
<style type="text/css">

/*Credits: Dynamic Drive CSS Library */
/*URL: http://www.dynamicdrive.com/style/ */

.suckertreemenu ul{
margin: 0;
padding: 0;
list-style-type: none;
font-family: Arial, Helvetica, sans-serif;
font-size: x-small;
font-style: normal;
font-weight: bold;
color: #FFFFFF;
background-color: #006633;
border: 1px solid #000000;
text-align: center;
white-space: normal;
line-height: normal;
font-variant: normal;
text-transform: capitalize;
text-decoration: none;
}

/*Top level list items*/
.suckertreemenu ul li{
position: relative;
display: inline;
float: left;
background-color: #006633;
font-family: Arial, Helvetica, sans-serif;
font-size: x-small;
font-style: normal;
font-weight: bold;
font-variant: normal;
text-transform: capitalize;
color: #FFFFFF;
text-decoration: none;
}

/*Top level menu link items style*/
.suckertreemenu ul li a{
display: block;
width: auto;
padding: 1px 4px;
border: 1px solid black;
text-decoration: none;
color: white;
overflow: visible;
}

/*1st sub level menu*/
.suckertreemenu ul li ul{
left: 0;
position: absolute;
width: auto;
top: 1em;
display: block;
visibility: hidden;
border: thin solid #000000;
overflow: visible;
}

/*Sub level menu list items (undo style from Top level List Items)*/
.suckertreemenu ul li ul li{
display: list-item;
float: none;
width: auto; /*Width of sub level menu list items*/
}

/*All subsequent sub menu levels offset after 1st level sub menu */
.suckertreemenu ul li ul li ul{
left: 159px; /* no need to change, as true value set by script */
top: 0;
width: auto; /*Width of subsequent sub menu items*/
}

/* Sub level menu links style */
.suckertreemenu ul li ul li a{
display: block;
width: auto;
color: white;
text-decoration: none;
border: 1px solid #000000;
width: auto;
}

.suckertreemenu ul li a:hover{
background-color:#003300
color: white;
border: 1px solid #000000;
}

/*Background image for top level menu list links */
.suckertreemenu .mainfoldericon{
background-color:#006633;
font-family: Arial, Helvetica, sans-serif;
font-size: x-small;
font-style: normal;
font-weight: bold;
font-variant: normal;
text-transform: capitalize;
color: #FFFFFF;
text-decoration: none;
border: 1px solid #000000;
}

/*Background image for subsequent level menu list links */
.suckertreemenu .subfoldericon{
border: 1px solid #000000;
}

* html p#iepara{ /*For a paragraph (if any) that immediately follows suckertree menu, add 1em top spacing between the two in IE*/
padding-top: 1em;
}

/* Holly Hack for IE \*/
* html .suckertreemenu ul li {
float: left;
height: 1%;
font-family: Arial, Helvetica, sans-serif;
font-size: x-small;
font-style: normal;
font-weight: bold;
font-variant: normal;
text-transform: capitalize;
color: #FFFFFF;
text-decoration: none;
}
* html .suckertreemenu ul li a {
height: 1%;
font-family: Arial, Helvetica, sans-serif;
font-size: x-small;
font-style: normal;
font-weight: bold;
font-variant: normal;
text-transform: capitalize;
color: #FFFFFF;
text-decoration: none;
background-color: #006633;
}
/* End */
Posted by TeeQ on 03/06, 02:22 PM
body {
background-color:#000000}
.style4 {
font-size: x-small;
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
color: #FFFFFF;
text-decoration: none;
background-color: #006633;
}
</style>

<script type="text/javascript">

//SuckerTree Horizontal Menu (Sept 14th, 06)
//By Dynamic Drive: http://www.dynamicdrive.com/style/

var menuids=["treemenu1"] //Enter id(s) of SuckerTree UL menus, separated by commas

function buildsubmenus_horizontal(){
for (var i=0; i<menuids.length; i++){
var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
for (var t=0; t<ultags.length; t++){
if (ultags[t].parentNode.parentNode.id==menuids[i]){ //if this is a first level submenu
ultags[t].style.top=ultags[t].parentNode.offsetHeight+"px" //dynamically position first level submenus to be height of main menu item
ultags[t].parentNode.getElementsByTagName("a")[0].className="mainfoldericon"
}
else{ //else if this is a sub level menu (ul)
ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px" //position menu to the right of menu item that activated it
ultags[t].parentNode.getElementsByTagName("a")[0].className="subfoldericon"
}
ultags[t].parentNode.onmouseover=function(){
this.getElementsByTagName("ul")[0].style.visibility="visible"
}
ultags[t].parentNode.onmouseout=function(){
this.getElementsByTagName("ul")[0].style.visibility="hidden"
}
}
}
}

if (window.addEventListener)
window.addEventListener("load", buildsubmenus_horizontal, false)
else if (window.attachEvent)
window.attachEvent("onload", buildsubmenus_horizontal)

</script>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>

<body>
<div align="center">
<table width="800" border="0" align="center">
<tr>
Posted by TeeQ on 03/06, 02:25 PM

Comment Pages 23 of 30 pages « First  <  21 22 23 24 25 >  Last »

Name: (Required)

Email: (Required)

(NOT shown on page)

URL:

(Shown on page if entered)

Comments: (Required)

Supported BB codes: [b], [i], [u], [em], [strike], [strong], [pre], [code], and [blockquote].

Remember my personal information
Notify me of follow-up comments?

Submit the word you see below ("previewing" post does not require it):


Copyright 2006-2008 Dynamic Drive Read our Usage Terms before using any of the CSS codes.
Dynamic Drive DHTML and CSS Code Library