• 【js 轮播图】


    效果图:

    html样式:

    <div id="box">
    			<img src="img/0.jpg" id="pir"/>	
    			<ul id="but">
    				<li>1</li>
    				<li>2</li>
    				<li>3</li>
    				<li>4</li>
    			</ul>
    			<div id="left"><</div>
    			<div id="right">></div>
    		</div>

    css样式:

    *{
    				margin: 0;
    				padding: 0;
    			}
    			#box{
    				 1000px;
    				height: 350px;
    				border:1px solid #ddd;
    				margin:0 auto;
    				position: relative;
    			}
    			img{
    				 100%;
    				height: 100%;
    			}
    			#but{
    				 160px;
    				height: 20px;
    				position: absolute;
    				bottom: 5%;
    				left: 45%;
    				list-style: none;
    			}
    			#but li{
    				float: left;
    				 25px;
    				height: 25px; 
    				background: antiquewhite;
    				border-radius: 50%;
    				margin-right: 10px;
    				text-align: center;
    				line-height: 25px;
    				cursor: pointer;
    			}
    			#left,#right{
    				font-size: 60px;
    				position: absolute;
    				top: 30%;
    				 0px;
    				height: 100px;
    				background:#EEE8AA;
    				line-height: 100px;
    				overflow: hidden;
    				transition: .5s;
    				cursor: pointer;
    			}
    			#left{left:10px;}
    			#right{right: 10px;}
    

     javasecipt效果:

    <script type="text/javascript">
    			var box =document.getElementById("box");
    			var Img = document.getElementById("pir");
    			var lis = document.getElementsByTagName("li");
    			var Left = document.getElementById("left");
    			var Right = document.getElementById("right");
    			var index = 0;
    			lis[0].style.backgroundColor = "darksalmon";
    //			定时器
    			var timer = setInterval(banner,2000);
    			
    			function banner(){
    				index++;
    				if(index == 4){
    					index = 0;
    				}
    				Img.src = "img/"+index+".jpg";
    				resetbg();
    				lis[index].style.backgroundColor = "darksalmon";
    			}
    			function resetbg(){
    				for(var i=0;i<lis.length;i++){
    					lis[i].style.backgroundColor = "antiquewhite";
    				}
    			}
    			for(var i=0;i<lis.length;i++){
    				lis[i].onclick = function(){
    					index = this.innerHTML - 1;
    					Img.src = "img/"+index+".jpg";
    					resetbg();
    					lis[index].style.backgroundColor = "darksalmon";
    				}
    			}
    			box.onmousemove = function(){
    				clearInterval(timer);
    				Left.style.width = Right.style.width ="50px";
    			}
    			box.onmouseout = function(){
    				timer = setInterval(banner,2000);
    				Left.style.width = Right.style.width ="0px";
    			}
    			Left.onclick = function(){
    				index--;
    				if(index == -1){
    					index = 3;
    				}
    				Img.src = "img/"+index+".jpg";
    				resetbg();
    				lis[index].style.backgroundColor = "darksalmon";
    			}
    			Right.onclick = function(){
    				index++;
    				if(index == 4){
    					index = 0;
    				}
    				Img.src = "img/"+index+".jpg";
    				resetbg();
    				lis[index].style.backgroundColor = "darksalmon";
    			}
    		</script>
    

      

  • 相关阅读:
    CentOS6.4 64位系统安装jdk
    oracle安装界面中文乱码解决
    亦步亦趋在CentOS 6.4下安装Oracle 11gR2(x64)
    CentOS 6.3(x86_64)下安装Oracle 10g R2
    Spring中映射Mongodb中注解的解释
    MongoDB 创建基础索引、组合索引、唯一索引以及优化
    MongoDB 用MongoTemplate查询指定时间范围的数据
    Java获取泛化类型
    SpringBoot标准Properties
    java如何获取一个对象的大小【转】
  • 原文地址:https://www.cnblogs.com/FFPING/p/8357991.html
Copyright © 2020-2023  润新知