下划线跟随导航

Original 2018-12-27 00:42:09 218
abstract:<!DOCTYPE html><html><head> <title>下划线跟随导航</title> <script type="text/javascript" src="jquery-3.3.1.min.js"></script> <style type="

<!DOCTYPE html>

<html>

<head>

<title>下划线跟随导航</title>

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

<style type="text/css">

  *{padding:0;margin:0;}

  .menu{background: red;height: 50px;width: 500px;border-radius: 5px;margin: 20px auto;margin-top: 20px;box-shadow: 0 2px 20px;position:relative;}

   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:50px;color: #ccc;font-weight: bold;}

</style>

<script type="text/javascript">

$(document).ready(function(){

$('li').hover(

function(){

$x = parseInt($(this).attr('name'))*100 //parseInt四舍五入,attr获取当前数值

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

},

function(){

$('.bock').stop().animate({left:'0px'},100)

}

)


})

</script>

</head>

<body>


<div class="menu">

<ul>

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

<li name="1">案例</li>

<li name="2">新闻</li>

<li name="3">咨询</li>

<li name="4">联系</li>

</ul>

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

</div>

</body>

</html>


Correcting teacher:查无此人Correction time:2018-12-27 09:25:13
Teacher's summary:做的不错。以后的作业,可以加上自己的总结。老师可以知道你的思路,给你一些指导

Release Notes

Popular Entries