下环线跟随你选中的导航菜单

Original 2019-03-27 19:49:34 217
abstract:导航菜单下有一个下划线,当鼠标指向某一菜单时,下划线跟随<!doctype html> <html> <head> <meta charset="UTF-8"> <title>下划线跟随</title> <script src="jquery/jquery-3.
导航菜单下有一个下划线,当鼠标指向某一菜单时,下划线跟随
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>下划线跟随</title>
<script src="jquery/jquery-3.3.1.min.js"></script>
<style>
*{margin: 0px;padding: 0px;}
ul{list-style:none;z-index: 20;position:relative;font-size: 16px;/*text-align: center;*/}
li{float:left; width: 100px;height: 32px;/*text-align: center;*/line-height: 32px;color: #fff;font-weight: bold;}
.daohang{width: 600px;position: relative;margin: 20px auto;height: 32px;background: #ccc;text-align: center;}

</style>
<script>
$(function(){
$("li").hover(
function(){
$a=parseInt($(this).attr("name"))*100;
$(".xiahuaxian").stop().animate({left:$a+"px"},300);
},
function(){
$(".xiahuaxian").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="width: 90px;height: 2px;background: red;position: absolute;top: 32px;z-index: 10;"></div>

</div>
</body>
</html>


Correcting teacher:天蓬老师Correction time:2019-03-28 10:01:45
Teacher's summary:这个作业, 一定要注意定位功能的使用, 跟踪用户的操作

Release Notes

Popular Entries