亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

下滑線跟隨導航

original 2019-02-20 15:20:00 249
abstrait:    要使下滑線跟隨導航,,需在jQuery中設置一個相關功能的函數,使鼠標移動‘li’時找到相關的name值并生成自定義動畫,再在之后設置一函數使鼠標不在‘li’標簽時默認在第一個標簽之下。完整代碼如下: <!DOCTYPE html> <html>  <head>   

    要使下滑線跟隨導航,,需在jQuery中設置一個相關功能的函數,使鼠標移動‘li’時找到相關的name值并生成自定義動畫,再在之后設置一函數使鼠標不在‘li’標簽時默認在第一個標簽之下。

完整代碼如下:

 <!DOCTYPE html>
<html>
 <head>
  <title>下滑線跟隨導航</title>
  <meta charset="utf-8"/>
  <script type="text/javascript" src="jquery-3.3.1.js"></script>
    <style type="text/css">
  *{padding:0;margin:0;}
  ul {list-style: none;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;font-family: 宋體;}
  .menu{width:500px;position:relative;margin:20px auto;height:32px;box-shadow: 10px 10px 100px #000;background: #9C44A8;border-radius:3px }
  </style>
  <script type="text/javascript">
    $(function(){
      $('li').hover(
        function(){
         $x=parseInt($(this).attr('name'))*100
         $('.box').stop().animate({left:$x+'px'},250)
        },
        function(){
          $('.box').stop().animate({left:'0px'},250)
        }   
        )
    })
  </script>
 </head>
 <body>
   <div class="menu">
   <ul>
     <li name="0">詹姆斯</li>
     <li name="1">濃眉</li>
     <li name="2">庫茲馬</li>
     <li name="3">球哥</li>
     <li name="4">英格拉姆</li>
   </ul>
  <div class="box" style="z-index:10;width:100px;height:2px;background:#000;position:absolute;top:30px;"></div>

 </div>
 
 </body>
</html>


Professeur correcteur:天蓬老師Temps de correction:2019-02-20 15:42:07
Résumé du professeur:<style type="text/css">, 里面的type屬性, 下次不要寫了,沒必要

Notes de version

Entrées populaires