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 ...
随机推荐
- MyRolan (快速启动小工具)
类似 Rolan的快速启动工具. 启动后隐藏,当鼠标移至左上角时,窗口显示,点击项目可运行程序. GitHub地址: MyRolan . #if defined(UNICODE) && ...
- window C/C++ 简单的IDE编译器
C-Free 官网链接: http://www.programarts.com/cfree_ch/download.htm
- springboot格式化时间
使用@RestController注解,返回的java对象中若含有date类型的属性,则默认输出为TIMESTAMP时间戳格式,可以在配置文件加入下面配置 spring.jackson.date-fo ...
- 分享一个VueCli 3.0的项目模板
个人搭建的Vue项目模板 默认自带 Vuex Less 封装内容如下 vue.config axios 封装 vue 配置环境文件 vue 自定义路径映射 (cli3.0取消了默认@ 映射src的 ...
- Debian 命令行方式配置网络
一.对于有线网络,如果默认没有安装图形界面,进入了 multi-user.target中时,是没有使用NetworkManager管理网络的,此时需要手动配置才能上网 首先得到网卡名称:ip addr ...
- MySQL5.7开启独立表空间参数innodb_file_per_table【原创】
今天在线上某个系统发现MySQL数据库使用的是共享表空间,想修改为独立表空间,操作如下: #因为是主从结构,在从库修改测试,先关闭binlog SET SQL_LOG_BIN=; show varia ...
- elk的备份与恢复【转】
elasticsearch提供了快照功能: 1.在elsticsearch的配置文件中定义一个path.repo路径配置 path.repo: ["/elk/my_backup"] ...
- 各种手工DIY
http://www.guokr.com/scientific/subject/diy/ 高仿宜家莲花灯 http://www.guokr.com/article/179863/ 做一只会发光的魔幻吊 ...
- Tensorflow笔记一
Tensorlfow中的计算是通过一个有向图directed graph或则计算图computation graph来实现的. 将每一个运算操作operation作为一个节点node,节点之间通过边e ...
- Web前端-网站首页和注册界面的实现
首页用到的知识如下: 1.bootstrap框架 2.jQuerry实现页面定时弹出广告 注册界面用到的知识: 1.bootstrap框架 2.jQuerry实现省市联动操作 3.jQuerry实现表 ...