JS 简单的轮播特效示例



<!doctype html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>html模板</title>
		<meta name="Keywords" content="关键词,关键词">
		<meta name="description" content="">
		<script type="text/javascript" src="f:/java/js/jquery.js"> </script>
		<!--css,js-->
		<style type="text/css">
			*{margin:0;padding:0;}
			.box{width:100%;height:450px;margin:0 auto;position:relative;z-index:0;}
			.box .pic{width:100%;height:450px;position:absolute;top:0;left:0;}
			.box .sel{width:120px;height:22px;position:absolute;bottom:10px;left:47%;border-radius:25px;background:rgba(0,0,0,.5);z-index:2;}
			.box .sel ul{margin-top:3px;margin-left:20px;display:inline-block;}
			.box .sel ul li{list-style:none;float:left;padding:0 5px;width:16px;height:16px;background:url('1.png') no-repeat center;cursor:pointer;}
			.box .sel .focus{width:16px;height:16px;background:url('2.png') no-repeat center;}
		</style>

	</head>
<body>

	<div class="box">
		<div class="pic" style="background:url('1.jpg') no-repeat center"></div>
		<div class="pic" style="background:url('2.jpg') no-repeat center"></div>
		<div class="pic" style="background:url('3.jpg') no-repeat center"></div>
		<div class="sel">
			<ul>
				<li class="focus"></li>
				<li></li>
				<li></li>
			</ul>
		</div>
	</div>

<script type="text/javascript"> 

	var mysetInterval = null;
	var s = 1;
	$(function(){
		$(".box").find("li").mouseover(function(){
			var _index = $(this).index();
			$(this).addClass("focus").siblings().removeClass("focus");
			$(".pic").css({"z-index":0,opacity:0})
			$(".pic").eq(_index).stop().css({"z-index":1}).fadeTo('slow',1)
			clearInterval(mysetInterval);
		},function(){
			play();
		});
		play();	
	});
	function play(){
		mysetInterval = setInterval(function(){
			if(s>3){
				s = 2;
			}
			$(".box").find("li").eq(s).addClass("focus").siblings().removeClass("focus");
			$(".pic").css({"z-index":0,opacity:0});
			$(".pic").eq(s).stop().css({"z-index":1}).fadeTo('slow',1);
			if(s==2){
				s=0;
			}else{
				s++;
			}
		},4000);
	}

</script>
</body>
</html



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值