返回下划线跟随导航...登陆

下划线跟随导航

斜杠大叔2019-04-23 10:08:13218

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8">

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

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

    <style type="text/css">

    *{margin: 0;padding: 0;}

    ul{

        list-style: none;

        position: relative;

        font-size: 15px;

        z-index: 20;

    }

    li{

        float: left;

        cursor: pointer;

        width: 100px;

        height: 30px;

        text-align: center;

        line-height: 30px;

        font-weight: bold;

    }

    li a{

        text-decoration: none;

        color: #fff;

    }

    .menu{

        width: 500px;

        position: relative;

        margin: 20px auto;

        height: 32px;

        box-shadow: 0 2px 20px #000;

        background: #af3434;

        border-radius: 3px;

    }

    </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 class="menu">

    <ul>

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

        <li name="1"><a href="">新闻中心</a></li>

        <li name="2"><a href="">产品中心</a></li>

        <li name="3"><a href="">招商加盟</a></li>

        <li name="4"><a href="">联系我们</a></li>

    </ul>

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

</div>

</body>

</html>


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送