首先,定义一个id为nav的ul,ul->li里面放的是下拉出来的菜单,也是一个ul:
2、js代码
3、css代码
#nav {
line-height: 24px; list-style-type: none;
}
#nav a {
display: block; text-align:center;
}
#nav a:link {
color:#a6ce38; text-decoration:none;
}
#nav a:visited {
color:#a6ce38;text-decoration:none;
}
#nav a:hover {
color:#F00; text-decoration:none;;
}
#nav li {
float: left; padding-left:15px; font-family:"微软雅黑"; font-size:14px;
}
#nav li a:hover{
color:#F00;
}
#nav li ul {
line-height:18px; list-style-type: none;text-align:left;
left: -999em; width:120px; position: absolute;
}
#nav li ul li{
background: #FFF;/*没有背景在ie6下会有一点小问题*/
float:left; width:100px;
font-family:"微软雅黑"; font-size:12px; color:#F00;
margin:0px;padding:0;
clear:both;
}
#nav li ul a{
display: block; width:100px;text-align:left;
}
#nav li ul a:link {
color:#a6ce38; text-decoration:none;
}
#nav li ul a:visited {
color:#a6ce38; text-decoration:none;
}
#nav li ul a:hover {
color:#FFF; text-decoration:none;
background:#F00;
}
#nav li:hover ul {
left: auto;
}
#nav li.sfhover ul {
left: auto;
}