- Home
- Categorie
- Coding e Sistemistica
- HTML e CSS
- Modifica css menu a tendina, da orizzontale a verticale
-
Modifica css menu a tendina, da orizzontale a verticale
salve ragazzi ho un problema con un menu a tendina, da orizzontale, dovrei disporlo in verticale. mi potete aiutare?
al seguente link lo potete vedere:
allevamenticinofilitaliani . c o m / menu /Codice html:
[PHP]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>JavaScript Dropdown Menu Demo</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<ul class="menu" id="menu">
<li><a href="#" class="menulink">Dropdown One</a>
<ul><li> <a href="#" class="sub">Navigation Item 2</a> <ul> <li class="topline"><a href="#">Navigation Item 1</a></li> <li><a href="#">Navigation Item 2</a></li> <li><a href="#">Navigation Item 3</a></li> <li><a href="#">Navigation Item 4</a></li> <li><a href="#">Navigation Item 5</a></li> </ul> </li> </ul> </li> <li><a href="#" class="menulink">Dropdown Two</a> <ul> <li> <a href="#" class="sub">Navigation Item 2</a> <ul> <li class="topline"><a href="#">Navigation Item 1</a></li> <li><a href="#">Navigation Item 2</a></li> <li><a href="#">Navigation Item 3</a></li> <li><a href="#">Navigation Item 4</a></li> <li><a href="#">Navigation Item 5</a></li> </ul> </li> </ul> </li>
</ul>
<script type="text/javascript">
var menu=new menu.dd("menu");
menu.init("menu","menuhover");
</script>
</body>
</html>
[/PHP]Codice css:
[PHP]
body {margin:25px; font:11px Verdana,Arial; background:#eee}
ul.menu {list-style:none; margin:0; padding:0}
ul.menu * {margin:0; padding:0}
ul.menu a {display:block; color:#000; text-decoration:none}
ul.menu li {position:relative; float:left; margin-right:2px}
ul.menu ul {position:absolute; top:26px; left:0; background:#d1d1d1; display:none; opacity:0; list-style:none}
ul.menu ul li {position:relative; border:1px solid #aaa; border-top:none; width:148px; margin:0}
ul.menu ul li a {display:block; padding:3px 7px 5px; background-color:#d1d1d1}
ul.menu ul li a:hover {background-color:#c5c5c5}
ul.menu ul ul {left:148px; top:-1px}
ul.menu .menulink {border:1px solid; padding:5px 7px 7px; font-weight:bold; background:url(images/header.gif); width:134px}
ul.menu .menulink:hover, ul.menu .menuhover {background:url(images/header_over.gif)}
ul.menu .sub {background:#d1d1d1 url(images/arrow.gif) 136px 8px no-repeat}
ul.menu .topline {border-top:1px solid}
[/PHP]Codice js:
[PHP]
var menu=function(){
var t=15,z=50,s=6,a;
function dd(n){this.n=n; this.h=[]; this.c=[]}
dd.prototype.init=function(p,c){
a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
for(i;i<l;i++){
var h=s*.parentNode; this.h*=h; this.c*=s*;
h.onmouseover=new Function(this.n+'.st('+i+',true)');
h.onmouseout=new Function(this.n+'.st('+i+')');
}
}
dd.prototype.st=function(x,f){
var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
clearInterval(c.t); c.style.overflow='hidden';
if(f){
p.className+=' '+a;
if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
if(c.mh==c.offsetHeight){c.style.overflow='visible'}
else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
}
function sl(c,f){
var h=c.offsetHeight;
if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
clearInterval(c.t); return
}
var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
c.style.opacity=o; c.style.filter='alpha(opacity='+(o100)+')';
c.style.height=h+(df)+'px'
}
return{dd:dd}
}();
[/PHP]
-
Ciao, prova così:
body {margin:25px; font:11px Verdana,Arial; background:#eee} ul.menu {list-style:none; margin:0; padding:0} ul.menu * {margin:0; padding:0} ul.menu a {display:block; color:#000; text-decoration:none} ul.menu li {position:relative; margin-right:2px} ul.menu ul {position:absolute; top:2px; left:148px; background:#d1d1d1; display:none; opacity:0; list-style:none} ul.menu ul li {position:relative; border:1px solid #aaa; border-top:none; width:148px; margin:0} ul.menu ul li a {display:block; padding:3px 7px 5px; background-color:#d1d1d1} ul.menu ul li a:hover {background-color:#c5c5c5} ul.menu ul ul {left:148px; top:-1px} ul.menu .menulink {border:1px solid; padding:5px 7px 7px; font-weight:bold; background:url(images/header.gif); width:134px} ul.menu .menulink:hover, ul.menu .menuhover {background:url(images/header_over.gif)} ul.menu .sub {background:#d1d1d1 url(images/arrow.gif) 136px 8px no-repeat} ul.menu .topline {border-top:1px solid} ```ho eliminato il float per le voci elenco e modificato i valori di top e left per ul.menu ul