• jQuery 图片轮播


    <html>
    <head>
    	<title>picture repeat</title>
    	<style type="text/css">
    		#container{
    			margin:0 auto;
    			 786px;/*轮播图片的宽度*/
    			height: 543px;/*轮播图片的高度*/
    			position: relative;
    			overflow: hidden;
    			z-index: 0;
    		}
    		#list{
    			position: absolute;
    			 4716px;
    			height: 543px;
    			z-index: 1;
    			left: -786px;
    		}
    		#list img{
    			float: left;
    		}
    		#left{
    			position: absolute;
    			left: 20px;
    			top: 270px;
    			display: none;
    			z-index : 2;
    			padding:8 15 8 15;
    			background-color: rgba(0,0,0,.3);
    			color: white;
    		}
    		#right{
    			position: absolute;
    			right: 20px;
    			top: 270px;
    			display: none;
    			z-index : 2;
    			padding:8 15 8 15;
    			background-color: rgba(0,0,0,.3);
    			color: white;
    		}
    		#container:hover .arrow{
    			display: block;
    		}
    		#left:hover{
    			background-color: rgba(0,0,0,.7);
    		}
    		#right:hover{
    			background-color: rgba(0,0,0,.7);
    		}
    		.arrow{
    			text-decoration: none;
    		}
    	</style>
    	<script type="text/javascript" src="jquery.js"></script>
    	<script type="text/javascript">
    		window.onload=function(){
    			var left = document.getElementById("left");
    			var right = document.getElementById("right");
    			var list = document.getElementById("list");
    			list.style.left = "-786px";
    			left.onclick = function(){
    				var newLeft = parseInt(list.style.left) - 786;
    				if(newLeft < -3144){
    					$("#list").animate({left: newLeft + "px"},function(){
    						list.style.left = "-786px";
    					});
    				}
    				else{
    					//list.style.left = newLeft + "px";
    					$("#list").animate({left: newLeft + "px"});
    				}		
    			};
    			right.onclick = function(){
    				var newLeft = parseInt(list.style.left) + 786;
    				if(newLeft > -786){
    					$("#list").animate({left: newLeft + "px"},function(){
    						list.style.left = "-3144px";
    					});
    				}
    				else{
    					//list.style.left = newLeft + "px";
    					$("#list").animate({left: newLeft + "px"});
    				}
    			};
    		};
    	</script>
    </head>
    <body>
    	<div id="container">
    		<div id="list">
    			<img src="4.png">
    			<img src="1.png">
    			<img src="2.png">
    			<img src="3.png">
    			<img src="4.png">
    			<img src="1.png">
    		</div>
    		<a id="left" href="#" class="arrow"><<</a>
    		<a id="right" href="#" class="arrow">>></a>
    	</div>
    </body>
    

      

  • 相关阅读:
    排序算法的实现(冒泡,选择,插入 O(N*N)--理解方法实现
    HTTPS工作原理和TCP握手机制
    HTTP协议学习
    IP头,TCP头,UDP头,MAC帧头定义
    单链表的实现
    数字图像处理------中值滤波
    对于矩阵的理解-- by 孟岩老师
    java编码问题总结
    jsp数据库连接大全和数据库操作封装到Javabean
    构建一个高可扩展性javabean和jsp连接数据库操作
  • 原文地址:https://www.cnblogs.com/chengshuiqiang/p/4718339.html
Copyright © 2020-2023  润新知