登录  /  注册
博主信息
博文 44
粉丝 0
评论 0
访问量 34437
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
JQuery下划线跟随导航
的博客
原创
674人浏览过

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <title>Document</title>
    <style>
        *{padding: 0;margin:0;}
        body{background-color: #ccc;}
        a{text-decoration:none}
        .header {
            background-color: #242424;
            width: 100%;
            height: 70px;
            border-bottom: 3px solid #C20C0C;
        }
        .wrap{
            margin: 0 auto;
            width: 1100px;
            height: inherit;
        }
        .wrap *{
            float: left;
        }
        .logo{
            width: 150px;
            height: inherit;
            position: relative;
        }
        .logo a{
            position: absolute;
            left: 0px;
            right: 0;
            top: 0;
            bottom: 0;
            margin: auto;
            line-height: 70px;
            text-align: center;
        }
        .menu{
            position:relative;
        }
        .nav {
            height: inherit;
            width:600px;
        }
        .nav li{
            width: 100px;
            height:inherit;
            line-height: 70px;
            text-align: center;
            list-style: none;
            font-size: 0.8rem;
            color: rgb(218, 218, 218);
            cursor: pointer;
        }

        .srch{
            width: 200px;
            height: inherit;
            position: relative;
        }
        .srch input{
            height: 30px;
            border: none;
            border-radius: 30px;
            text-align: center;
            position: absolute;
            left: 20px;
            right: 0;
            top: 0;
            bottom: 0;
            margin: auto;
        }
        .login {
            width: 150px;
            height: inherit;
            position: relative;
        }
        .login a{
            font-size: 0.4rem;
            color: #ccc;
            width: 80px;
            height: 35px;
            line-height: 35px;
            text-align: center;
            position: absolute;
            left: 10px;
            right: 0;
            top: 0;
            bottom: 0;
            margin: auto;
            background: #242424; 
            border:1px rgb(105, 105, 105) solid;
            border-radius: 35px;
        }
    </style>
    <script type="text/javascript">
        $(document).ready(function () {
            $(".nav li").hover(function () {
                $li_n=parseInt($(this).attr("name"))*100;
                $(".block").stop().animate({left:$li_n+"px",width:"100px"},500)
                // $x=parseInt($(this).attr('name'))*100
                // $('.block').stop().animate({left:$x+'px',width:'100px'},300)
                
            }, function () {
                // out
                $(".block").stop().animate({width:"0"},500)
            }
        );
        });
      </script>
</head>

<body>
    <div class="header">
        <div class="wrap">
            <h1 class="logo"><a href="">LOGO</a></h1>
            <div class="menu">
                    <ul class="nav">
                            <li name="0">发现音乐</li>
                            <li name="1">我的音乐</li>
                            <li name="2">朋友</li>
                            <li name="3">商城</li>
                            <li name="4">音乐人</li>
                            <li name="5">下载客户端</li>
                    </ul>
                    <div class="block" style="z-index:10;height:3px;background:#fff;position:absolute;top:70px;"></div>
            </div>
            <div class="srch"><input type="text" placeholder="音乐/视频/电台/用户"></div>
            <div class="login"><a href="">登录</a></div>
        </div>
    </div>
</body>

</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例


本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学