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: Vertical CSS Menus: Here

SuckerTree Vertical Menu (v1.1)

Author: Dynamic Drive

Nov 8th, 06: Fixed rendering issue in IE7, plus added support for automatic detection of sub menus width. No more configuring the "left" attributes!

This is a vertical, predominantly CSS based (with a touch of JavaScript) multi-level menu. It supports as many sub levels as you desire, plus multiple Suckertree menus on the same page. The CSS and JavaScript automatically adopts to your HTML code in each case.

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 behavior to them. This differs from Suckerfish menu, which merely uses JavaScript to compensate for IE's shortcomings when it comes to CSS, so the menu is more rigid and requires manual changes to the CSS as the number of levels in your menu changes.

Demo:

The single image:

The CSS:

The HTML:

Code Info

Rate this code:

Date Posted: 11/08/2006

Revision History: Updated Nov 8th, 06' to version 1.1

Usage Terms: Click here

Your Comments (247)

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 17 of 25 pages « First  <  15 16 17 18 19 >  Last »

works everywhere of course except in IE! bastards.
any ideas?
Posted by tori on 10/01, 07:59 PM
There is a problem in Javascript.

use this java script instead and menu will work as it should.

<code>
<script type="text/javascript">

//SuckerTree Vertical Menu 1.1 (Nov 8th, 06)
//By Dynamic Drive: http://www.dynamicdrive.com/style/

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

function buildsubmenus(){
for (var i=0; i<menuids.length; i++){
var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
for (var t=0; t<ultags.length; t++){
ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle"
if (ultags[t].parentNode.parentNode.id==menuids[i]) //if this is a first level submenu
ultags[t].style.left=ultags[t].parentNode.offsetWidth+"px" //dynamically position first level submenus to be width of main menu item
else //else if this is a sub level submenu (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.onmouseover=function(){
this.getElementsByTagName("ul")[0].style.display="block"
}
ultags[t].parentNode.onmouseout=function(){
this.getElementsByTagName("ul")[0].style.display="none"
}
}
for (var t=ultags.length-1; t>-1; t--){ //loop through all sub menus again, and use "display:none" to hide menus (to prevent possible page scrollbars
ultags[t].style.visibility="visible"
ultags[t].style.display="none"
}
}
}

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

</script>
<code>

[i]Peace...[/i]
Posted by Deuexx on 10/03, 05:21 AM
How can i make the sub menus over the slide show which is based in Java?
Posted by Mikey on 10/16, 05:24 PM
how do I make a selected submenu stay open via a class

<li class="selected">Folder 2.1
<ul>
<li>Sub Item 2.1.1</li>
<li>Sub Item 2.1.2</li>
<li>Sub Item 2.1.3</li>
<li>Sub Item 2.1.4</li>
<li>Sub Item 2.1.5</li>
<li>Sub Item 2.1.6</li>
</ul>
</li>
Posted by doug on 10/17, 04:02 PM
I've tried this script, but can't to seem to get it working.
All I get is the first menu list, and not an option for the second set with >>
Any ideas?
Posted by Liza on 10/20, 02:22 AM
I am trying to change the font style to Verdana and can't seem to get it to work. When I do change it the submenus disappear after you hover over the first one. The rest of the submenus then are not accessible. Please help. Love this menu!
Posted by Monika McLachlan on 10/21, 10:39 PM
I am trying to change the font style to Verdana and can't seem to get it to work. When I do change it the submenus disappear after you hover over the first one. The rest of the submenus then are not accessible.

Still need help for this if anyone can help.
http://www.kidscancercare.ab.ca/kccf/wigstest.htm
Posted by Monika McLachlan on 10/23, 09:46 PM
Didn't work on I.E. 7 the submenus items!!
Posted by lostlocke on 10/29, 06:37 AM
Everything is working great but the page won't validate XHTML 1.0 Transitional because of the javascript.

When I put the javascript in as a link, the menu doesn't work. Any ideas?

-----this is what is in common.js ---
var menuids=["suckertree1"]

function buildsubmenus(){
for (var i=0; i<menuids.length; i++){
var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")
for (var t=0; t<ultags.length; t++){
ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle"
if (ultags[t].parentNode.parentNode.id==menuids[i])
ultags[t].style.left=ultags[t].parentNode.offsetWidth+"px"
else //else if this is a sub level submenu (ul)
ultags[t].style.left=ultags[t-1].getElementsByTagName("a")[0].offsetWidth+"px"
ultags[t].parentNode.onmouseover=function(){
this.getElementsByTagName("ul")[0].style.display="block"
}
ultags[t].parentNode.onmouseout=function(){
this.getElementsByTagName("ul")[0].style.display="none"
}
}
for (var t=ultags.length-1; t>-1; t--){
ultags[t].style.visibility="visible"
ultags[t].style.display="none"
}
}
}

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

---
the link I put above the css link
<script src="common.js" language="javascript" type="text/javascript"></script>
Posted by Suzanne Wright on 11/03, 01:37 PM
I have been using the vertical CSS menus and I would like to incorporate the vertical menus with the CSS Left and Top frames layout.

The problem I am having is the submenus appear to be behind the maincontent frame area.

Please tell me there is a simple fix to get the sub menu options to be visible?

I know they are there because changing the 'overflow:' from hidden to scroll (which puts the scroll bar on the bottom of the left frame area) I can see the scroll bar change the scroll area size when I mouse over the menu items with a second menu option, but of course there is no way to get to the scroll bar.

Also removing the div class="innertube" from that area allows me to see the left edge of the sub menu, but not even the first letter, and some of my menu items are 2 sub menus deep anyway.

Help please....

Thanks much, great code BTW.
Posted by Rob B on 11/08, 01:52 PM

Comment Pages 17 of 25 pages « First  <  15 16 17 18 19 >  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