1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>丝滑版导航条</title> <style type="text/css"> *{ margin: 0; padding: 0; } ul{ list-style: none; width: 400px; height: 40px; line-height: 40px; border:2px solid gold; margin: 40px auto; display: flex; justify-content: space-between; text-align: center; position: relative; } li{ width: 50px; } #slide{ width: 40px; height: 2px; background-color: green; position: absolute; left: 5px; bottom: 4px; } </style> </head> <body> <ul> <li>娱乐</li> <li>军事</li> <li>历史</li> <li>财经</li> <li>民生</li> <li>汽车</li> <li>疫情</li> <li>国内</li> <div id="slide"></div> </ul> </body> </html> <script src="js/jquery-3.5.1.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript"> $("ul li").mouseenter(function(){
$("#slide").stop().animate({ left:$(this).index() * 50 + 5 }, 300) }); </script>
|