加上这个界面好友善的感觉

原创 2018-11-22 15:31:22 299
摘要:<!DOCTYPE html> <html> <head>     <meta charset="UTF-8">     <title>下划线跟随导航</title>    &n
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>下划线跟随导航</title>
    <script type="text/javascript" src="jquery-3.3.1.min.js"></script>
    <style type="text/css">
        *{padding:0;margin:0;}
        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;}
        .menu{
            width: 500;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'},100)
                },
                function () {
                    $('.block').stop().animate({left:'0px'},100)
                }
                )
        })
    </script>
</head>
<body>
    <div>
        <ul>
            <li name="0">首页</li>
            <li name="1">php中文网</li>
            <li name="2">独孤九剑</li>
            <li name="3">西门大官人</li>
            <li name="4">灭绝师太</li>
        </ul>
    </div>
    <div style="z-index: 20;width:100px;height:2px;background: #fff;position: absolute;top: 50px;"></div>
</body>
</html>

增加用户体验,赞

批改老师:灭绝师太批改时间:2018-11-22 17:12:38
老师总结:随着知识点的增多,效果会越来越完善的,继续加油!

发布手记

热门词条