摘要:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>下滑线跟随导航</title><script type="text/javascript" src="jquery-3.3.1.min.js">
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>下滑线跟随导航</title>
<script type="text/javascript" src="jquery-3.3.1.min.js"></script>
<style type="text/css">
*.{padding:0;margin: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:550px;position:relative;margin:20px auto;height:32px;box-shadow:0 2px 20px #000;background:#af3434;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>
<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>
批改老师:天蓬老师批改时间:2018-12-11 15:59:26
老师总结:jquery中的自定义动画功能非常强大, 可以实现许多有意思的东西