Ciao a tutti,
ho trovato questo bellissimo script per un menu ad albero...
vi posto l'esempio che potete vedere: http://grapho.calafurialivorno.it/menu2/
sotto vi posto il codice delle 3 pagine ... ma prima la richiesta...
dunque, come vedere il menu si "espande" al passaggio del mouse... e va benissimo.. però per un solo "sotto-livello".
Sto cercando di capire se è possibile farlo espandere anche per i sotto-sotto-livelli e così via...
sapete dirmi se si come posso fare ?
grazie
ecco le pagine:
pagina html/php
Codice PHP:
<!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=iso-8859-1" />
<title>JavaScript Dropdown Menu Demo</title>
<link rel="stylesheet" href="flyout.css" type="text/css" />
<script type="text/javascript" src="flyout.js"></script>
</head>
<body>
<div id="wrapper">
<div id="leftcolumn">
<dl class="dropdown">
<dt id="one-ddheader" class="upperdd" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)">Dropdown One</dt>
<dd id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)">
<ul>[*][url="#"]Navigation Item 1[/url][*][url="#"]Navigation Item 2[/url][*][url="#"]Navigation Item 3[/url][/list]
</dd>
</dl>
<dl class="dropdown">
<dt id="two-ddheader" class="upperdd" onmouseover="ddMenu('two',1)" onmouseout="ddMenu('two',-1)">Dropdown Two</dt>
<dd id="two-ddcontent" onmouseover="cancelHide('two')" onmouseout="ddMenu('two',-1)">
<ul>[*][url="#"]Navigation Item 1[/url][*][url="#"]Navigation Item 2[/url][*][url="#"]Navigation Item 3[/url][*][url="#"]Navigation Item 4[/url][*][url="#"]Navigation Item 5[/url][/list]
</dd>
</dl>
<dl class="dropdown">
<dt id="three-ddheader" class="upperdd">Menu Item Three</dt>
</dl>
<dl class="dropdown">
<dt id="four-ddheader" onmouseover="ddMenu('four',1)" onmouseout="ddMenu('four',-1)">[url="#"]Dropdown Four[/url]</dt>
<dd id="four-ddcontent" onmouseover="cancelHide('four')" onmouseout="ddMenu('four',-1)">
<ul>[*][url="#"]Navigation Item 1[/url]
[*][url="#"]Navigation Item 2[/url][/list]
</dd>
</dl>
</div>
<div id="rightcolumn">
Lorem ipsum....
</div>
</div>
</body>
</html>
pagina CSS
Codice PHP:
* {padding:0; margin:0}
body {font:12px Verdana, Arial, Helvetica}
#wrapper {width:750px; padding:25px; margin:0 auto}
#leftcolumn {float:left; width:225px}
#rightcolumn {float:left; width:525px}
.dropdown {display:block; position:relative}
.dropdown dt {display:block; width:188px; border:2px solid #9ac1c9; padding:8px; font-weight:bold; cursor:pointer; /*background:url(images/header.gif)*/ background:#CCFFFF;}
.dropdown dt:hover {/*background:url(images/header_over.gif)*/ background:#CCCCFF}
.dropdown a {display:block; text-decoration:none; color:#333}
.dropdown a:hover {color:#000}
.dropdown .upperdd {border-bottom:none}
.dropdown dd {position:absolute; top:0; overflow:hidden; width:208px; display:none; background:#fff; opacity:0}
.dropdown ul {width:204px; border:2px solid #9ac1c9; list-style:none}
.dropdown li {display:inline}
.dropdown ul a, .dropdown ul a:active, .dropdown ul a:visited {padding:5px; background:#eaf0f2; width:194px}
.dropdown ul a:hover {background:#d9e1e4}
.dropdown .underline {border-bottom:1px solid #b9d6dc}
PAGINA JS
Codice PHP:
var DDSPEED = 10;
var DDTIMER = 15;
var OFFSET = -2;
var ZINT = 100;
function ddMenu(id,d){
var h = document.getElementById(id + '-ddheader');
var c = document.getElementById(id + '-ddcontent');
clearInterval(c.timer);
if(d == 1){
clearTimeout(h.timer);
c.style.display = 'block';
if(c.maxh && c.maxh <= c.offsetHeight){return}
else if(!c.maxh){
c.style.left = (h.offsetWidth + OFFSET) + 'px';
c.style.height = 'auto';
c.maxh = c.offsetHeight;
c.style.height = '0px';
}
ZINT = ZINT + 1;
c.style.zIndex = ZINT;
c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
}else{
h.timer = setTimeout(function(){ddCollapse(c)},50);
}
}
function ddCollapse(c){
c.timer = setInterval(function(){ddSlide(c,-1)},DDTIMER);
}
function cancelHide(id){
var h = document.getElementById(id + '-ddheader');
var c = document.getElementById(id + '-ddcontent');
clearTimeout(h.timer);
clearInterval(c.timer);
if(c.offsetHeight < c.maxh){
c.timer = setInterval(function(){ddSlide(c,1)},DDTIMER);
}
}
function ddSlide(c,d){
var currh = c.offsetHeight;
var dist;
if(d == 1){
dist = Math.round((c.maxh - currh) / DDSPEED);
}else{
dist = Math.round(currh / DDSPEED);
}
if(dist <= 1 && d == 1){
dist = 1;
}
c.style.height = currh + (dist * d) + 'px';
c.style.opacity = currh / c.maxh;
c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
if(currh > (c.maxh - 2) && d == 1){
clearInterval(c.timer);
}else if(dist < 1 && d != 1){
clearInterval(c.timer);
c.style.display = 'none';
}
}
grazie!