摘要:demo.html: <!DOCTYPE html> <html lang="en"> <head> <title>頁(yè)面中常用平級(jí)下拉菜單(手風(fēng)琴)</title> <link rel="stylesheet" href="static/css
demo.html: <!DOCTYPE html> <html lang="en"> <head> <title>頁(yè)面中常用平級(jí)下拉菜單(手風(fēng)琴)</title> <link rel="stylesheet" href="static/css/demo.css"> <link rel="stylesheet" href="static/font-awesome/css/font-awesome.min.css"> <link rel="shortcut icon" href="static/images/logo.png" type="image/x-icon"> <script src="static/js/jquery.js"></script> </head> <body> <div class="nav"> <div class="parent"> <div class="one"> <strong>個(gè)人中心</strong> </div> <ul class="two"> <li><a href=""></a>我的信息</li> <li><a href=""></a>系統(tǒng)通知</li> <li><a href=""></a>短信息</li> </ul> </div> <div class="parent"> <div class="one"> <strong>課程中心</strong> </div> <ul class="two"> <li><a href=""></a>我的信息</li> <li><a href=""></a>系統(tǒng)通知</li> <li><a href=""></a>短信息</li> <ul> </div> <div class="parent"> <div class="one"> <strong>校內(nèi)討論</strong> </div> <ul class="two"> <li><a href=""></a>我的信息</li> <li><a href=""></a>系統(tǒng)通知</li> <li><a href=""></a>短信息</li> </ul> </div> <div class="parent"> <div class="one"> <strong>資源中心</strong> </div> <ul class="two"> <li><a href=""></a>我的信息</li> <li><a href=""></a>系統(tǒng)通知</li> <li><a href=""></a>短信息</li> </ul> </div> </div> <script> $(function(){ $('.two').css('display','none'); var one=$('.one'); var two=$('.two'); //each() 方法規(guī)定為每個(gè)匹配元素規(guī)定運(yùn)行的函數(shù)。 $('.one').each(function(i){ $(this).click(function(){ if($(two[i]).css('display')=='none'){ $(two[i]).slideDown(400) }else{ $(two[i]).slideUp(400) }; }); }); }); </script> </body> </html> demo.css: *{ margin: 0px; padding: 0px; font-size: 14px; font-family: "微軟雅黑"; } a{ text-decoration:none; color: #36b2f5; } .nav{ width: 250px; margin: 70px auto; border-top: 4px solid #36b2f5; border-bottom: 3px solid #36b2f5; } .nav .one{ border-bottom: 1px solid #36b2f5; border-right: 1px solid #36b2f5; border-left: 1px solid #36b2f5; height: 40px; line-height: 40px; text-align: center; cursor: pointer; } .two{ width: 248px; border-right: 1px solid #36b2f5; border-left: 1px solid #36b2f5; } .two li{ list-style: none; height: 35px; line-height: 35px; text-align: center; border-bottom: 1px dotted #36b2f5; }
批改老師:滅絕師太批改時(shí)間:2019-03-18 16:58:06
老師總結(jié):完成的不錯(cuò),除了上課案例,還可以自行拓展.