前端轮播图,无缝衔接
2018-01-19 15:02
267 查看
1.假设三张图片轮播,首先要把三张图放在一个div里,但只显示一张图
<div class="window" style="width:1140px">
<div class="image_reel" style="width:4560px">
<a href="#"><img src="1.jpg" alt="" /></a>
<a href="#"><img src="2.jpg" alt="" /></a>
<a href="#"><img src="3.jpg" alt="" /></a>
<a href="#"><img src="1.jpg" alt="" /></a>
</div>
</div>
.window{
height: 300px;
width: 1140px;
overflow: hidden;
position: relative;
}
.image_reel{
position: absolute;
top: 0;
left: 0px;
}
.image_reel img{
width: 1140px;
height: 300px;
float: left;
}
2.做定时器,定时移动position的left的位置
3.无缝衔接,在轮播到第三张时,不是直接把position的left定位到0px上,这样的话,会有突兀感,而是先动画移动到第四张的图1中,同时用回调函数把left定位到0px上
$(".image_reel").animate({
left:-image_reelPosition //3*imgeWidth
},500,function(){
$(this).css({'left':'0px'});
});
<div class="window" style="width:1140px">
<div class="image_reel" style="width:4560px">
<a href="#"><img src="1.jpg" alt="" /></a>
<a href="#"><img src="2.jpg" alt="" /></a>
<a href="#"><img src="3.jpg" alt="" /></a>
<a href="#"><img src="1.jpg" alt="" /></a>
</div>
</div>
.window{
height: 300px;
width: 1140px;
overflow: hidden;
position: relative;
}
.image_reel{
position: absolute;
top: 0;
left: 0px;
}
.image_reel img{
width: 1140px;
height: 300px;
float: left;
}
2.做定时器,定时移动position的left的位置
3.无缝衔接,在轮播到第三张时,不是直接把position的left定位到0px上,这样的话,会有突兀感,而是先动画移动到第四张的图1中,同时用回调函数把left定位到0px上
$(".image_reel").animate({
left:-image_reelPosition //3*imgeWidth
},500,function(){
$(this).css({'left':'0px'});
});
相关文章推荐
- 滑动轮播图实现最后一张图片无缝衔接第一张图片
- jquery实现图片无缝轮播显示(由这里开始记录前端)
- 图片右轮播第一张和最后一张无缝衔接
- HTML5 animation 无缝轮播
- js实现文字无缝向上轮播
- js 轮播图无缝连接
- banner轮播无缝滚动 jq代码
- jq 实现无缝轮播
- js原生轮播图 —— 无缝滚动的原理
- 用原生JS写无缝轮播
- 无缝轮播的实现与封装
- 无缝轮播图 源码
- web前端基础案例-简短代码制作爱奇艺首页导航轮播特效
- 例子---JS无缝轮播图
- HTML_用参数判断轮播-小标签-文字图片轮播-第一挪到最后的无缝滚动轮播
- 【实践】纯jquery实现图片滑动无缝轮播,带左右按钮及控制按钮
- 原生JS实现轮播+学前端的感受(防止走火入魔)
- jquery手写焦点轮播图-------解决最后一张无缝跳转第一张的问题
- js实现图片无缝向左轮播