下划线跟随导航

Original 2018-10-21 20:55:51 192
abstract:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Document</title><script src="https://code.jquery.com/jquery-3.1.1.min.js"></scr

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

<style type="text/css">

        *{margin: 0px;padding: 0px;}

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

        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;}

</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>



Release Notes

Popular Entries