摘要:<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>下滑先跟随导航</title> <script type="
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>下滑先跟随导航</title>
    <script type="text/css" src="../jquery-3.4.1.min.js"></script>
    <style type="text/css">
 *{margin: 0px;padding: 0px}
 ul{list-style-type: 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: #ffffff;font-weight: bold}
        .menu{width: 700px;position: relative;margin: 20px auto;height: 32px;box-shadow: 0 2px 20px orangered;background: pink;border-radius: 3px}
 </style>
    <script type="text/javascript">
 $(function () {
 $('li').hover(
 function () {
 $x=parseInt($(this).attr('name'))*100;
 $('.block').stop().animate({left:$x+'px'},300)
            },
 function () {
 $('.block').stop().animate({left:'0px'},300)
                }
            )
        })
 </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>
           <li name="5">资源下载</li>
           <li name="6">菜鸟随堂</li>
       </ul>
       <div class="block" style="z-index: 10;width: 100px;height: 2px;background: orangered;position: absolute;top: 30px;"></div>
   </div>
</body>
</html>
						批改老师:天蓬老师批改时间:2019-05-28 16:58:02		
						
老师总结:下划线跟随着鼠标移动,  是通过一些事件来实现, 这样的效率 , 还是很多方法来实现可以试试看					
 
                 
 
 
  
            