abstract:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <script src="https://code.jquery.com/jquery-3.1.1.min.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Document</title> <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> <style> *{margin:0;padding: 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;box-shadow: 0 2px 20px #000;background-color: lightblue;border-radius: 3px;height: 32px;} </style> <script> $(function () { $('li').hover( function(){ $x=parseInt($(this).attr('name'))*100 $('.block').stop().animate({left:$x+'px'},200) } , function(){ $x=parseInt($(this).attr('name'))*100 $('.block').stop().animate({left:'0px'},200) } ) }) </script> </head> <body> <div> <ul> <li name="0">首页</li> <li name="1">产品</li> <li name="2">联系</li> <li name="3">招聘</li> <li name="4">企业文化</li> </ul> <div style="z-index: 10;width: 100px;height: 2px;background: #fff;position: absolute;top:30px;"></div> </div> </body> </html>
Correcting teacher:天蓬老师Correction time:2019-04-13 16:25:40
Teacher's summary:<div style="z-index: 10;width: 100px;height: 2px;background: #fff;position: absolute;top:30px;"></div>
</div>你这个div的内联为什么不写到上面style中呢?一个页面不要出现太多其它方式的样式规则