サマリー:<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>下滑線跟隨導(dǎo)航</title> <script type="text/javascript" src="j
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>下滑線跟隨導(dǎo)航</title> <script type="text/javascript" src="jquery.min.js"></script> <style type="text/css"> *{padding: 0;margin: 0;} ul {list-style: none;z-index: 20;position: relative;font-size: 15px;} li {float: left;cursor: pointer;width: 100px;height: 30px;text-align: center;line-height: 30px;color: #fff;font-weight: bold;} .menu {width: 500px;position: relative;margin: 20px auto;height: 32px;box-shadow: 0 2px 20px #000;background: #AF3434;border-radius: 3px;} </style> </head> <body> <div class="menu"> <ul> <li name="0">首頁</li> <li name="1">PHP</li> <li name="2">Mysql</li> <li name="3">Jquery</li> <li name="4">Html</li> </ul> <div class="block" style="z-index: 10;width: 100px;height: 2px;background: #fff;position: absolute;top: 30px;"></div> </div> <script type="text/javascript"> $(function(){ $('li').hover( function(){ $x = parseInt($(this).attr('name'))*100; $('.block').stop().animate({left:$x+'px'},500); }, function(){ $('.block').stop().animate({left:'0px'},500); } ) }) </script> </body> </html>
添削の先生:滅絕師太添削時(shí)間:2019-03-25 09:26:31
先生のまとめ:完成的很好,練習(xí)可以對(duì)照老師代碼,但是要確保下次遇到相同效果自己可以完成