JQuery实现旋转轮播图
css部分
<style>
*{
margin:;
padding:;
}
.container{
width:100%;
height:353px;
margin-top: 20px;
}
.prev{
display: block;
width:50px;
height:50px;
background:url(img/prev.png);
position: absolute;
left: 110px;
top:192px;
z-index:;
}
.next{
display: block;
width:50px;
height:50px;
background:url(img/next.png);
position: absolute;
right:110px;
top:192px;
z-index:;
}
ul li{
position: absolute;
list-style: none;
display: none;
}
ul{position:relative;margin:0 auto;width:1000px;}
ul li img{width:100%;}
li.banner1{display:block;width:500px;left:100px;top:60px;z-index:}
li.banner2{display:block;width:599px;left:200px;top:40px;z-index:}
li.banner3{display:block;width:500px;right:100px;top:60px;z-index:}
</style>
html部分
<div class="container">
<a href="javascrpt:;" class="prev"></a>
<a href="javascrpt:;" class="next"></a>
<ul>
<li class="banner1"><img src="img/4.png" /></li>
<li class="banner2"><img src="img/1.png" /></li>
<li class="banner3"><img src="img/2.png" /></li>
<li><img src="img/3.png" /></li>
</ul>
</div>
JQuery部分
<script>
//0-1
//1-2
//2-3
//3-0 //0-3
//1-0
//2-1
//3-2 $(function(){
var arr = [];
$("ul>li").each(function(i,o){
arr.push({left:$(o).position().left,top:$(o).position().top,width:$(o).width(),zIndex:$(o).css("zIndex")});
});
var isPrev = true;
var prev_in = 3;
var prev_out = 2;
var next_out = 0;
var next_in = 3;
$(".prev").click(function(){
if(isPrev){
isPrev = false;
arr.push(arr[0]);
arr.shift();
$("ul>li").each(function(i,o){
if(i == prev_out){
$(o).fadeOut(200,function(){
isPrev = true;
});
}
else if(i == prev_in){
$(o).css({left:arr[i].left,top:arr[i].top,width:arr[i].width,zIndex:arr[i].zIndex}).fadeIn(200);
}
else{
$(o).css({zIndex:arr[i].zIndex}).animate({left:arr[i].left,top:arr[i].top,width:arr[i].width},200);
}
});
next_out = prev_in;
next_in = prev_out;
prev_in--;
prev_out--;
if(prev_out == -1){
prev_out = 3;
}
if(prev_in == -1){
prev_in = 3;
}
}
});
var isNext = true;
$(".next").click(function(){
if(isNext){
isNext = false;
arr.unshift(arr[arr.length-1]);
arr.pop();
$("ul>li").each(function(i,o){
if(i == next_out){
$(o).fadeOut(200,function(){
isNext = true;
});
}
else if(i == next_in){
$(o).css({left:arr[i].left,top:arr[i].top,width:arr[i].width,zIndex:arr[i].zIndex}).fadeIn(200);
}
else{
$(o).css({zIndex:arr[i].zIndex}).animate({left:arr[i].left,top:arr[i].top,width:arr[i].width},200);
}
});
prev_in = next_out;
prev_out = next_in;
next_out++;
next_in++;
if(next_out == 4){
next_out = 0;
}
if(next_in == 4){
next_in = 0;
}
}
});
});
</script>
JQuery实现旋转轮播图的更多相关文章
- jQuery自适应-3D旋转轮播图
3D旋转轮播图 本例源于(站长之家实例http://sc.chinaz.com/jiaoben/170215391070.htm) 其他相似示例(https://www.cnblogs.com/inc ...
- 基于jQuery的移动轮播图(支持触屏)
移动轮播图我看到两款, 一款是无线天猫的m.tmall.com,实现了无缝轮播. 一款是蘑菇街的,没有实现无缝轮播. 我自己重写一个,类似蘑菇街 <!doctype html> <h ...
- JS封装动画框架,网易轮播图,旋转轮播图
JS封装动画框架,网易轮播图,旋转轮播图 1. JS封装运动框架 // 多个属性运动框架 添加回调函数 function animate(obj,json,fn) { clearInterval(ob ...
- 用jQuery实现轮播图效果,js中的排他思想
---恢复内容开始--- jQuery实现轮播图不用单独加载. 思路: a. 通过$("#id名");选择需要的一类标签,获得一个伪数组 b.由于是伪数组的原因,而对数组的处理最多 ...
- 用js和jQuery做轮播图
Javascript或jQuery做轮播图 css样式 <style> a{ text-decoration:none; } .naver{ width: 100%; position:r ...
- WPF特效-实现弧形旋转轮播图
原文:WPF特效-实现弧形旋转轮播图 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u013224722/article/details/77004 ...
- JS-特效 ~ 05. 缓动框架兼容封装/回掉函数/兼容透明度/层级、旋转轮播图、正则表达式、验证表单注册账号、
缓动函数中opcity 写百分值的值 JS一般不用小数运算,会照成精度丢失 元素的默*认透明度是 层级一次性赋值,不缓动 利用for…in为同一个父元素的子元素绑定属性 缓动框架兼容封装/回掉函数/ ...
- jQuery 简单滑动轮播图效果
一般页面简单轮播图效果用jQuery制作更加简单.我们来看看以下效果是如何来进行制作的. 其html结构下所示: <div id="box"> < ...
- 自实现PC端jQuery版轮播图
最近其他项目不是很忙,被安排给公司的官网项目做一个新的页面(之前没接触公司官网项目),其中有一个用到轮播图的地方,最开始想直接用swiper.js插件实现就好了,可是发现官网项目里之前都没有引入过sw ...
随机推荐
- SqlServer变量
MySql变量 => https://www.cnblogs.com/fanqisoft/p/10700669.html 全局变量 局部变量 ⒈全局变量 以@@开头,后面跟相应的字符串,全局变量 ...
- Access denied for user ‘root’@‘localhost’(using password: YES)的解决方法
https://www.jb51.net/article/133836.htm 搭建服务器之后只能看见test与infomation_schema两个库 https://www.cnblogs.com ...
- 2018-2019-2-20175225 实验一 《Java开发环境的熟悉》实验报告
2018-2019-2-20175225 实验一 <Java开发环境的熟悉>实验报告 一.实验内容及知识点 实验内容 1.使用JDK编译.运行简单的Java程序: 2.使用IDEA编辑.编 ...
- docker安装小笔记
作者:邓聪聪 yum update Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker docker卸载旧版本(如 ...
- stylus 实践
音乐分享: Broken Back - <Halcyon Birds> —————————————————————————————————————————————————————————— ...
- IDEA中执行MAVEN命令打jar包
SpringBoot Jar包打包 1.工程POM配置packaging为jar. <packaging>jar</packaging> 2.增加MAVEN运行配置 添加MAV ...
- python学习第32天
# 使用模块操作进程# multiprocessing 一个多元化的进程模块# multiple 多元化 processing 进程 # 涵盖了和进程相关的几乎所有的内容# Process类 帮助你启 ...
- tensorflow--交叉熵
学而不思则罔,思而不学则怠. 最近在看<TensorFlow 实战Google深度学习框架第二版>这本书.从头开始学习深度学习,对于细节方面进行探究.相当于重新拾起来这门”手艺“. 这篇随 ...
- A - Alice's Print Service ZOJ - 3726 (二分)
Alice is providing print service, while the pricing doesn't seem to be reasonable, so people using h ...
- 高可用Redis(十三):Redis缓存的使用和设计
1.缓存的受益和成本 1.1 受益 1.可以加速读写:Redis是基于内存的数据源,通过缓存加速数据读取速度 2.降低后端负载:后端服务器通过前端缓存降低负载,业务端使用Redis降低后端数据源的负载 ...