zoukankan      html  css  js  c++  java
  • 带左右按钮、 渐隐渐现 轮播图

    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="UTF-8">
    		<title></title>
    		<style type="text/css">
    			*{
    				margin: 0;
    				padding: 0;
    			}
    			#outer{
    				position: relative;
    				 800px;
    				height: 450px;
    				overflow: hidden;
    				margin: 50px auto 0;
    			}
    			#outer img{
    				position: absolute;
    				 800px;
    				height: 450px;
    				opacity: 0;
    			}
    			#outer #show{
    				opacity:1;
    			}
    			#prePage{
    				position: absolute;
    				left: 0;
    				top: 50%;
    				 50px;
    				height: 100px;
    				background: rgba(0,0,0,0.5);
    				line-height: 100px;
    				text-align: center;
    				font-size: 40px;
    				color: white;
    				margin-top: -50px;
    			}
    			#nextPage{
    				position: absolute;
    				right: 0;
    				top: 50%;
    				 50px;
    				height: 100px;
    				background: rgba(0,0,0,0.5);
    				line-height: 100px;
    				text-align: center;
    				font-size: 40px;
    				color: white;
    				margin-top: -50px;
    			}
    		</style>
    	</head>
    	<body>
    		
    		<div id="outer">
    			<img src="img/1.jpg" alt=""  id="show"/>
    				<img src="img/10.jpg" alt="" />
    				<img src="img/11.jpg" alt="" />
    				<img src="img/12.jpg" alt="" />
    				<img src="img/2.jpg" alt="" />
    			<span id="prePage"><</span><span id="nextPage">></span>
    		</div>
    		
    		<script src="js/jquery-2.2.1.min.js"> </script>
    		<script>
    		
    			var page = 0;
    			var time = null;
    			var time1= null;
    			var time2 = null;
    			run()
    			function run(){
    				time = setInterval(function(){
    					page++;
    					if(page>4)
    					{
    						page = 0;
    					}
    					ani();
    				},3000);
    			}
    			
    			$("#prePage").click(function(){
    				clearInterval(time);
    				clearTimeout(time1);
    
    				page--;
    				if(page<0)
    				{
    					page = 4;
    				}
    				console.log(page);
    				$("#outer>img").stop();
    				ani();
    				time1 = setTimeout(function(){
    					run();
    				},1000)
    
    				
    			})
    			
    			$("#nextPage").click(function(){
    				clearInterval(time);
    				clearTimeout(time2);
    				page++;
    				if(page > 4)
    				{
    					page = 0;
    				}
    				console.log(page);
    				$('#outer>img').stop();
    				ani();
    				time2 = setTimeout(function(){
    					run();
    				},1000)
    
    				
    			})
    			
    			function ani(){
    				$("#outer>img").eq(page).siblings("img").animate({"opacity":"0"},500,function(){
    					$("#outer>img").eq(page).animate({"opacity":1},500);
    				})
    			}
    		</script>
    		
    	</body>
    </html>
    

      

  • 相关阅读:
    JavaIO学习:字符流
    Java学习:IO流
    Java中的Filter过滤器
    Java学习:File类中的过滤器接口
    Java学习:File类
    Java学习:递归
    多线程简介(全)
    Java学习:Lambda表达式
    Java学习:线程池
    Java学习:线程间通信
  • 原文地址:https://www.cnblogs.com/mingjixiaohui/p/5254965.html
Copyright © 2011-2022 走看看