zoukankan      html  css  js  c++  java
  • JQ菜单滑块

    网站导航滑块效果:

     

    复制以下代码保存到html文件中即可查看效果...

    <html>
    <head>
        <title>JQ菜单滑块</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    	<style type="text/css">
    		.nav{
    			605px;
    			height:50px;
    			background-color:#999;
    			position:relative;
    		}
    		.nav>ul{
    			100%;
    			height:100%;
    			background-color:#177cb0;
    			list-style:none;
    			float:left;
    			margin: 0;
    			padding: 0;
    		}
    		.nav>ul>li{
    			100px;
    			height:50px;
    			line-height:50px;
    			float:left;
    			background-color:#666;
    			text-align:center;
    			margin-left:1px;
                            color:#fff;
    	        }
    		.nav>ul>li:first-child{
    			margin-left:0;
    		}
    		.fmove{
    			100px;
    			height:5px;
    			position:absolute;
    			z-index:10;
    			left:0;
    			bottom:0;
    			background-color:blue;
    		}
    	</style>
        <script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
    	
    </head>
    <body>
        <div class="nav">
    		<ul>
    			<li>首页</li>
    			<li>菜单1</li>
    			<li>菜单2</li>
    			<li>菜单3</li>
    			<li>菜单4</li>
    			<li>菜单5</li>
    		</ul>
    		<div class="fmove"></div>
    	</div>
    </body>
    </html>
    <script type="text/javascript">
        $(function () {
    		var tt;
    		$(".nav>ul>li").hover(function(){
    			clearTimeout(tt);			
    			var lft = $(this).position().left;
    			tt = setTimeout('$(".fmove").animate({left:' + lft + '})',450);
    		});
            $(".nav").mouseleave(function(){
    			clearTimeout(tt);		
    			tt = setTimeout('$(".fmove").animate({left:0})',650);
    		});
        });
    </script>
    

      

  • 相关阅读:
    cookie
    手写Promise/Promise.all/promise.race
    Hbuilder如何真机调试?
    什么是深拷贝?什么是浅拷贝?如何实现深拷贝?
    Vue.set()?怎么用?
    vueRouter怎么用?
    Vue如何实现组件间通信?
    reduce()累加器
    filter()数组遍历
    map()数组遍历
  • 原文地址:https://www.cnblogs.com/melman/p/4510839.html
Copyright © 2011-2022 走看看