<!DOCTYPE html> <html> <head> <title>document</title> <meta charset="utf-8"/> <script type="text/javascript" src="jquery.js"></script> <style type="text/css"> *{padding:0;margin:0;} ul {list-style: none;z-index:20;position:relative;font-size: 15px;} li:last-child{border-width: 0} li {border-right:1px solid #CCC;float:left;cursor:pointer;width:100px;height: 32px;text-align:center;line-height:32px;color: #fff;font-weight: bold;} .menu{width:504px;position:relative;margin:20px auto;height:32px;;background: rgb(0, 111, 236);border-radius:3px;border:1px solid rgb(0, 111, 236); } .block{z-index:10;width:100px;height:2px;background:#fff;position:absolute;top:0px;} </style> <script type="text/javascript"> $(function(){ $('li').hover( function(){ $x=parseInt($(this).attr('name'))*101 $('.block').stop().animate({left:$x+'px'}) }, function(){ $('.block').stop().animate({left:'0px'}) } ) }) </script> </head> <body> <div class="menu"> <ul> <li name="0">首页</li> <li name="1">菜单1</li> <li name="2">菜单2</li> <li name="3">菜单3</li> <li name="4">菜单4</li> </ul> <div class="block"></div> </div> </body> </html>