jquery导航栏下划线跟随,老师请通过下,谢谢

原创 2018-12-16 23:49:09 111
摘要:<!DOCTYPE html><html><head> <title></title> <script type="text/javascript" src="jquery-3.3.1.min.js"></script> <style type="text/c

<!DOCTYPE html>

<html>

<head>

<title></title>

<script type="text/javascript" src="jquery-3.3.1.min.js"></script>

<style type="text/css">

*{margin: 0;padding:0;}

ul{list-style: none;font-size: 15px;z-index: 20;position: relative;}

.menu{width: 500px;height: 40px;margin:20px auto;border-radius: 3px;position: relative;background: #af3434;box-shadow: 0 2px 20px;}

li{float: left;cursor: pointer;width: 100px;height: 40px;line-height: 40px;text-align: center;color: #fff;font-weight: bold;}

</style>

</head>

<body>

<div class="menu">

<ul>

<li name='0'>首页</li>

<li name='1'>PHP中文网</li>

<li name='2'>灭绝师太</li>

<li name='3'>独孤九剑</li>

</ul>

<div class="block" style="z-index: 10;width: 100px;height: 2px;background: #fff;position: absolute;top: 40px;"></div>

</div>

<script type="text/javascript">

$(function(){

$('li').hover(function(){

$x=parseInt($(this).attr('name')*100)

$('.block').stop().animate({left:$x+'px'},200)

},function(){

$('.block').stop().animate({left:'0px'},200)

}

})

</script>

</body>

</html>


批改老师:灭绝师太批改时间:2018-12-17 09:24:59
老师总结:你这个作业完成 的迅速啊,但是要确保知识点准确掌握奥!

发布手记

热门词条