Na podstawie http://www.alistapart.com/articles/dropdowns/ zrobiłem takie testowe menu rozwijane. Chciałbym je jednak nieco zmodyfikować ale pomysły mi się skończyły i nie bardzo wiem jak ten temat dalej ruszyć. Działający kod wygląda tak:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <style type="text/css"> body{ background : grey;} #top .menu{ padding : 0; margin : 0 auto; height : 30px; width : 300px; text-align : center; background : red;} #top .menu ul{ padding : 0; margin : 0 auto; list-style : none; float : none;} #top .menu li{ position : relative; margin : 0; text-align : center; height : 30px; float : left; width : 100px;} #top .menu a{ margin : 0; padding : 0 0 10px 0; display : block;} #top .menu a:hover{ margin : 0; padding : 0 0 10px 0; background : white; display : block;} #top .menu li ul{ display : none; position : absolute; top : 0; left : 0;} #top .menu li > ul { top : auto; left : auto;} #top .menu li:hover ul, li.over ul{ display : block; background : green; margin : 0;} </style> 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; //--><!]]></script> </head> <body> <div id="top"> <div class="menu"> <ul id="nav"> <ul> </ul> </li> </ul> </div> </div> </body> </html>
I teraz jak najeżdża się na menu to tło zmienia się na białe. Następnie gdy najedziemy na któreś podmenu to wtedy ono też robi się białe jednak tło głównego menu wraca do koloru czerwonego w tym przypadku. Efekt jaki chciałbym osiągnąć to po najechaniu na podmenu, menu główne dalej pozostaje podświetlone na biało. Maci na to jakiś pomysł może?