水平方向的PopMenu-弹出菜单(DIV+CSS+JS)

http://www.corange.cn//uploadfiles/1017-5_28171.jpg


<style type="text/css">
li ul {
display: none;
left: -40px;
position: absolute;
top: 24px;
width: 490px; /*opera需要这个宽度,可根据导航条的实际宽度作调整*/
}

li ul li{
display: inline;
}

li ul li a{
background: url(h_line.gif) no-repeat 0px 7px;
color: #666666;
font-weight: normal;
padding: 6px;
text-align: left;
}

li ul li a:hover{
background: url(h_line.gif) no-repeat 0px 7px;
color: #DC4E1B;
text-decoration: underline;
}

li ul,li ul li{
border: 0px;
}
li:hover ul, li.over ul,ul li:hover {
display: block;
}

ul {
list-style: none;
margin: 0px;
padding: 0px;
font: normal 11px verdana;
}

ul li {
border: solid 1px #CCCCCC;
border-left: 0px;
float: left;
position: relative;
}

ul li a {
background: #F5F5F5;
color: #666666;
display: block;
font-weight: bold;
padding: 5px 10px;
text-align: center;
text-decoration: none;
}

ul li a:hover {
background: #DC4E1B;
color: #FFFFFF;
}

.left{
height: 24px;
width: 1px;
}
</style>

<SCRIPT language=JavaScript type=text/JavaScript>
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>

<ul id="nav"><li class="left"></li><li><a href="#">Home</a></li>
<li><a href="#">About</a><ul> <li><a href="#">Sub menu 21</a></li>
<li><a href="#">Sub menu 22</a></li> <li><a href="#">Sub menu 23</a></li>
<li><a href="#">Sub menu 24</a></li> </ul> </li> <li><a href="#">Products</a>
<ul> <li><a href="#">Sub menu 31</a></li> <li><a href="#">Sub menu 32</a></li>
<li><a href="#">Sub menu 33</a></li> <li><a href="#">Sub menu 34</a></li></ul>
</li> <li><a href="#">Services</a><li><a href="#">Contact Us</a></li></ul>

你可能感兴趣的:(JavaScript,css,Opera)