Blogger Information
Blog 20
fans 0
comment 0
visits 13986
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
jQuery动画导航条-2019年1月24日22点39分
kszyd的博客
Original
613 people have browsed it

实例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>jQuery导航条动画效果</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <style>
        *{margin: 0;padding: 0}
        .box{
            width: 100%;
            height: 70px;
            background: #f5f5f5;
            box-shadow: 1px 1px 10px #ccc; 
            line-height: 70px; 
            position: relative;
            top: -65px;      
        }
        form{
            width: 800px;
            margin: 0 auto; 
            position: relative;           
        }
        input{
            width: 800px;
            height: 35px;
            border: none;
            border-radius: 4px;             
            padding-left: 15px;
        }
        form i{
            font-size: 28px;
            position: absolute;
            top:0;
            right: 10px;
        }
        span{
            position: absolute;
            width: 48px;
            height: 48px;
            display: block;
            background: url(images/show.jpg) -64px 168px;
            right: 0;
        }
        .menu{
            width: 1000px;
            height: 40px;
            line-height: 40px;
            margin: 20px auto;
            background: #f5f5f5;
        }
        .menu li{
            float: left;
            text-align: center;
            width: 10%;
            font-weight: bold;
        }
        .one li:hover a{
            color: #fff;
        }
        .three li{
            position: relative;
        }
        .three li i{
            font-size: 12px;
            margin-left: 8px;
        }
        .three li ul{
            width: 100px;
            box-shadow: 0 2px 5px #f5f5f5;
            position: absolute;
        }
        .three li ul li{
            width: 100px;
            line-height: 40px;
        }
        .three li ul li:hover{
            background: #f5f5f5;
        }
    </style>
</head>
<body>
    <div class="box">
        <form>
            <input type="text" placeholder="# 请输入关键词 #">
            <i class="layui-icon layui-icon-search"></i>
        </form>
        <span></span>
    </div>
    <ul class="menu one">
        <li><a href="">首页</a></li>
        <li><a href="">二页</a></li>
        <li><a href="">三页</a></li>
        <li><a href="">四页</a></li>
        <li><a href="">五页</a></li>
        <li><a href="">六页</a></li>
        <li><a href="">七页</a></li>
        <li><a href="">八页</a></li>
        <li><a href="">九页</a></li>
        <li><a href="">十页</a></li>
    </ul>
    <ul class="menu two" style="position:relative;">
        <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>
        <li name="5"><a href="">六页</a></li>
        <li name="6"><a href="">七页</a></li>
        <li name="7"><a href="">八页</a></li>
        <li name="8"><a href="">九页</a></li>
        <li name="9"><a href="">十页</a></li>
        <div class="ba" style="position: absolute;width: 100px;height: 3px;background: #ff6500;top:37px;"></div>
    </ul>
    <ul class="menu three">
        <li><a href="">首页</a></li>
        <li><a href="">二页</a></li>
        <li><a href="">三页</a></li>
        <li><a href="">四页</a></li>
        <li><a href="">五页</a></li>
        <li><a href="">六页</a></li>
        <li><a href="">七页</a></li>
        <li><a href="">八页</a></li>
        <li><a href="">九页</a></li>
        <li><a href="">十页</a><i class="layui-icon layui-icon-up"></i>
            <ul>
            <li><a href="">下一</a></li>
            <li><a href="">下二</a></li>
            <li><a href="">下三</a></li>
            </ul>
        </li>
     </ul>
    <script>
        $(function(){
            $('input').focus(function(){
                $(this).css('box-shadow','0 0 5px #ff6500 inset');
            })
            $('input').blur(function(){
                $(this).css('box-shadow','');
            })
            $('.box').hover(function(){
                $(this).stop().animate({'top':'2px'},500);//鼠标移入效果
            },function(){
                $(this).stop().animate({'top':'-65px'},500);//鼠标移出效果
            })
            $('.one>li').hover(function(){
                $(this).css('background','#ff6500');
            },function(){
                $(this).css('background','#f5f5f5');
            })
            $('.two>li').hover(function(){
                $x=parseInt($(this).attr('name'))*100;
                $('.ba').stop().animate({left:$x+'px'},100);
            },function(){
                $('.ba').stop().animate({left:0},100);
            })
            $('.three ul').hide();
            $('.three>li').hover(function(){
                $(this).find('i').attr('class','layui-icon layui-icon-down');
                $(this).find('ul').slideDown(300);
            },function(){
                $(this).find('i').attr('class','layui-icon layui-icon-up');
                $(this).find('ul').slideUp();
            })
        })
    </script>
    
</body>
</html>

运行实例 »

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

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!