您好,登錄后才能下訂單哦!
效果:
代碼:
<!DOCTYPE html>
<html>
<head>
<title>js實(shí)現(xiàn)下拉列表</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">
/*
鼠標(biāo)離開事件
*/
function hidesubment (li) {
//獲取子菜單對(duì)象
var submenuobj = li.getElementsByClassName("nav-ul-li-ul")[0];
//設(shè)置顯示的屬性
submenuobj.style.display = "none";
}
/*
鼠標(biāo)經(jīng)過事件
*/
function showsubmenu (li) {
//獲取對(duì)象
var submenuobj = li.getElementsByClassName("nav-ul-li-ul")[0];
//設(shè)置顯示的屬性
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="">關(guān)于我們</a></li>
</ul>
</div>
</body>
</html>
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。