您好,登录后才能下订单哦!
效果:
代码:
<!DOCTYPE html>
<html>
<head>
<title>js实现下拉列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
*{margin: 0px;padding: 0px}
.nav{background-color: #eee;width: 600px;height: 40px;margin: 0 auto;}
.nav-ul{list-style: none;}
.nav-ul li{float: left;line-height: 40px;text-align: center;position: relative;}
.nav-ul li a {text-decoration: none;color: #000;display: block;padding:0 10px;}
.nav-ul li a:hover{color: #FFF;background-color: #666}
.nav-ul li .nav-ul-li-ul{position: absolute;left: 0px; top:40px;display: none;}
.nav-ul li .nav-ul-li-ul li {list-style: none; float: none;background-color: #eee;margin-top: 2px;}
.nav-ul li .nav-ul-li-ul li a:hover{color: #FFF;background-color: #36e}
</style>
<script type="text/javascript">
/*
鼠标离开事件
*/
function hidesubment (li) {
//获取子菜单对象
var submenuobj = li.getElementsByClassName("nav-ul-li-ul")[0];
//设置显示的属性
submenuobj.style.display = "none";
}
/*
鼠标经过事件
*/
function showsubmenu (li) {
//获取对象
var submenuobj = li.getElementsByClassName("nav-ul-li-ul")[0];
//设置显示的属性
submenuobj.style.display = "block";
}
</script>
</head>
<body>
<div class="nav">
<ul class="nav-ul">
<li><a href="">首页</a></li>
<li onmouseout="hidesubment(this)">
<a href="">我的课程</a>
<ul class="nav-ul-li-ul">
<li><a href="">java</a></li>
<li><a href="">php</a></li>
</ul>
</li>
<li><a href="">关于我们</a></li>
</ul>
</div>
</body>
</html>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。