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{
			width:605px;
			height:50px;
			background-color:#999;
			position:relative;
		}
		.nav>ul{
			width:100%;
			height:100%;
			background-color:#177cb0;
			list-style:none;
			float:left;
			margin: 0;
			padding: 0;
		}
		.nav>ul>li{
			width: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{
			width: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>

  

转载于:https://www.cnblogs.com/melman/p/4510839.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值