abstract:<!DOCTYPE html><html><head> <title>下滑线跟随导航</title> <meta charset="utf-8"> <script type="text/javascript" src="../jquery-3.4.0.min.js&quo
<!DOCTYPE html>
<html>
<head>
<title>下滑线跟随导航</title>
<meta charset="utf-8">
<script type="text/javascript" src="../jquery-3.4.0.min.js"></script>
<script>
$(function(){
$('li').hover(
function(){
$x=parseInt($(this).attr('name'))*120
$('.block').stop().animate({left:$x+'px'},300)
},
function(){
$('.block').stop().animate({left:'0px'},300)
}
)
})
</script>
<style type="text/css">
*{padding: 0;margin: 0}
ul{list-style: none;font-size: 15px;}
li{float: left;height: 30px;line-height: 30px;width: 120px;text-align: center;color: #fff;font-weight: bold; }
.menu{width: 720px;height: 32px;background: #AF3434;margin: 20px auto;border-radius: 3px;box-shadow: 0 2px 20px #000;position: relative;}
.block{width: 120px;height: 2px;background:#fff;position: absolute;top: 30px}
</style>
</head>
<body>
<div class="menu">
<ul>
<li name="0">首页</li>
<li name="1">QQ飞车</li>
<li name="2">DNF地下城</li>
<li name="3">刀剑神域</li>
<li name="4">Fate剑灵</li>
<li name="5">LOL银熊联盟</li>
</ul>
<div class="block"></div>
</div>
</body>
</html>
Correcting teacher:天蓬老师Correction time:2019-04-28 08:47:48
Teacher's summary:这种下划线跟随模式, 可以提升用户体验 , 实现起来也不难, 可以让用户知道自己正在做什么....