我在页面底部而不是顶部有一个导航栏。我正在尝试实现一个“下拉”吸盘菜单。我想用尽可能少的 javascript 来做到这一点。我当前的代码如下,可以作为下拉菜单正常工作。有没有办法扭转它?
这是我的代码:
<style type="text/css">
#nav, #nav ul {
padding: 0;
margin: 0;
list-style: none;
}
#nav a {
display: block;
width: 10em;
}
#nav li {
float: left;
width: 10em;
background: #000000;
}
#nav li ul {
position: absolute;
left: -999em;
}
#nav li: hover ul {
left: auto;
}
#nav li:hover ul, #nav li.sfhover ul {
left: auto;
}
</style>
<script type="text/javascript">
sfHover = function() {
var sfEls = document.getElementById("nav").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
</script>
<ul id="nav">
<li><a href="#">Home</a></li>
<li><a href="#">About Us</a>
<ul>
<li><a href="#">Who We Are</a></li>
<li><a href="#">What We Believe</a></li>
<li><a href="#">Our Pastors</a></li>
</ul>
</li>
<li><a href="#">Ministries</a>
<ul>
<li><a href="#">Victory Kids (VC3)</a></li>
<li><a href="#">Victory Youth</a></li>
<li><a href="#">Connect Groups</a></li>
<li><a href="#">S.O.A.P</a></li>
<li><a href="#">Victory Group</a></li>
</ul>
</li>
<li><a href="#">Connect</a>
<ul>
<li><a href="#">Contact Us</a></li>
<li><a href="#">Social Networks</a></li>
<li><a href="#">Blogs</a></li>
</ul>
</li>
<li><a href="#">Media</a>
<ul>
<li><a href="#">Sermon Podcasts</a></li>
<li><a href="#">Videos</a></li>
<li><a href="#">Images</a></li>
</ul>
</li>
<li><a href="#">Giving</a>
<ul>
<li><a href="#">Help Support</a></li>
<li><a href="#">Ministries We Support</a></li>
<li><a href="#">2011 Financial Report</a></li>
</ul>
</li>
<li><a href="#">Resources</a></li>
</ul>
感谢所有帮助。谢谢!