abstrakt:<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>三級下拉菜單</title> <script type="text/javascript" src="jquery-3.3.1
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>三級下拉菜單</title> <script type="text/javascript" src="jquery-3.3.1.min.js"></script> <style type="text/css"> *{margin: 0px;padding: 0px;} .menu { width:600px;height: 35px;margin: 0px auto;background: #000; margin-top: 20px;color: #fff; border:1px solid #ccc;border-radius: 5px; } ul{ list-style: none;} ul li {width: 100px;height: 35px;line-height: 35px;text-align: center;float: left;border-right: 1px solid #ccc;cursor: pointer;margin: 0px auto; } .twobox li {width: 100px;height: 30px;line-height: 30px;background: #2D2D2D;color: #A9A9A9; font-size: 14px;position: relative;border:0px;} .twobox li:hover {background: #000;color: #fff;} .three {position: absolute; top: 0px;left: 100px;} .three li {width: 99px;height: 30px;line-height: 30px;border: 0px;} </style> <script type="text/javascript"> //改變標(biāo)簽的背景顏色的函數(shù) function changeColor(tag) { var len=document.getElementsByTagName(tag).length for(var i=0;i<len;i++){ document.getElementsByTagName(tag)[i].style.backgroundColor='rgb('+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+','+Math.floor(Math.random()*256)+')' } } $(function(){ //隱藏二級與三級下拉菜單 $('.twobox').hide() $('.three').hide() //當(dāng)鼠標(biāo)移動到包含二級菜單的一級菜單時顯示當(dāng)前二級菜單 $('.one li').mouseover(function(){ $(this).find('.twobox').slideDown(500) }) //當(dāng)鼠標(biāo)移出包含二級菜單的一級菜單時隱藏當(dāng)前二級菜單 $('.one li').mouseleave(function(){ $(this).find('.twobox').slideUp(500) }) //當(dāng)鼠標(biāo)移動到包含三級菜單的二級菜單時顯示當(dāng)前三級菜單 $('.two').mouseover(function(){ $(this).find('.three').slideDown(500) }) //當(dāng)鼠標(biāo)移出包含三級菜單的二級菜單時隱藏當(dāng)前三級菜單 $('.two').mouseleave(function(){ $(this).find('.three').slideUp(500) }) //調(diào)用函數(shù)獲取隨機顏色 changeColor('li') //當(dāng)鼠標(biāo)在上面是 $('li').mouseover(function(){ $bg=$(this).css('backgroundColor') $(this).css('box-shadow','0px 0px 20px '+$bg) $(this).css('border-radius','20px ') }) //當(dāng)鼠標(biāo)離開的時候 $('li').mouseleave(function(){ $(this).css('box-shadow','none') $(this).css('border-radius','0px') }) }) </script> </head> <body> <div class="menu"> <ul class="one"><!-- 一級下拉菜單 one --> <li>首 頁 </li> <li>商品分類 <ul class="twobox"><!-- 二級下拉菜單 twobox--> <li class="two">男人 <ul class="three"><!--三級下拉菜單 three--> <li>外套</li> <li>情侶裝</li> <li>夾克</li> <li>毛衣</li> </ul> </li> <li class="two">箱包 <ul class="three"><!--三級下拉菜單 three--> <li>產(chǎn)品1.1</li> <li>產(chǎn)品1.2</li> <li>產(chǎn)品1.3</li> <li>產(chǎn)品1.4</li> </ul> </li> <li class="two">數(shù)碼 <ul class="three"> <li>電腦</li> <li>手機</li> <li>相機</li> <li>手表</li> </ul> </li> <li>女人</li> </ul> </li> <li>我的淘寶 <ul class="twobox"> <li>以買到的寶貝</li> <li class="two">我的足跡 </li> <li>我的上新</li> <li>淘寶達人</li> </ul> </li> <li>購物車</li> <li>收藏夾</li> </ul> </div> </body> </html>
Korrigierender Lehrer:韋小寶Korrekturzeit:2018-11-21 15:56:09
Zusammenfassung des Lehrers:寫的很不錯!下次還記得加上代碼高亮哦!還有下次作業(yè)也得有總結(jié)哦!