第三部:让它运作起来
我们需要在我们移动到主菜单上时显示副菜单内容:
以下为引用的内容: li:hover ul { display: block; } |
好了,你可以测试下代码了,1%人可能会兴奋地叫起来,呵呵遗憾的是就目前这些代码还不能够在IE上运做作出我们想要的结果.要让IE运作出一样的效果,我们得使用一段JS代码,不会非常的烦琐:
|
以下为引用的内容: 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;
|
好了,其他代码再做下补充,这个功能就能实现了:
以下为引用的内容: li:hover ul, li.over ul { display: block; }
<ul id="nav"> |
自己动手做一个吧,可以更好看些