裁剪法实现_图片无缝左右切换
2017-02-22 00:00
405 查看
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>裁剪法实现---无缝左右切换</title>
<meta name="Keywords" content="关键字,关键字">
<meta name="description" content="">
<style type="text/css">
*{margin:0px;padding:0px;}
body{font-size:12px;font-family:"微软雅黑";color:#666;}
/* start scroll */
#scroll{width:512px;height:384px;margin:100px auto 0;border:1px solid #DDD;position:relative;}
#scroll img.prev{position:absolute;top:167px;left:20px;}
#scroll img.next{position:absolute;top:167px;right:20px;}
#scroll .list{width:512px;height:384px;background:#CFF;overflow:hidden;position:relative;}
#scroll .list ul{width:4000px;height:384px;position:absolute;}
#scroll .list ul li{width:512px;height:384px;float:left;list-style:none;}
/* scroll end */
</style>
</head>
<body>
<!-- start scroll -->
<div id="scroll">
<div class="list">
<ul>
<li><img src="images/1.jpg" width="512" height="384" alt=""/></li>
<li><img src="images/2.jpg" width="512" height="384" alt=""/></li>
<li><img src="images/3.jpg" width="512" height="384" alt=""/></li>
<li><img src="images/4.jpg" width="512" height="384" alt=""/></li>
<li><img src="images/5.jpg" width="512" height="384" alt=""/></li>
<li><img src="images/6.jpg" width="512" height="384" alt=""/></li>
<li><img src="images/7.jpg" width="512" height="384" alt=""/></li>
</ul>
</div>
<img src="images/prev.png" width="50" height="50" alt="" class="prev"/>
<img src="images/next.png" width="50" height="50" alt="" class="next"/>
</div>
<!-- scroll end -->
<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
<script type="text/javascript">
$("#scroll img.prev").click(function() {
$(".list ul").prepend($(".list ul li:last"));
$(".list ul").css("left", "-512px");
$(".list ul").animate({"left" : "0px"}, 500);
});
$("#scroll img.next").click(function() {
$(".list ul").animate({"left" : "-512px"}, 500, function() {
$(".list ul").append($(".list ul li:first"));
$(".list ul").css("left", "0px");
});
});
var autoPlay = setInterval(function() {
$("#scroll img.next").click();
}, 2000);
$(".list ul").hover(function() {
clearInterval(autoPlay);
}, function() {
autoPlay = setInterval(function() {
$("#scroll img.next").click();
}, 2000);
});
</script>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>裁剪法实现---无缝左右切换</title>
<meta name="Keywords" content="关键字,关键字">
<meta name="description" content="">
<style type="text/css">
*{margin:0px;padding:0px;}
body{font-size:12px;font-family:"微软雅黑";color:#666;}
/* start scroll */
#scroll{width:512px;height:384px;margin:100px auto 0;border:1px solid #DDD;position:relative;}
#scroll img.prev{position:absolute;top:167px;left:20px;}
#scroll img.next{position:absolute;top:167px;right:20px;}
#scroll .list{width:512px;height:384px;background:#CFF;overflow:hidden;position:relative;}
#scroll .list ul{width:4000px;height:384px;position:absolute;}
#scroll .list ul li{width:512px;height:384px;float:left;list-style:none;}
/* scroll end */
</style>
</head>
<body>
<!-- start scroll -->
<div id="scroll">
<div class="list">
<ul>
<li><img src="images/1.jpg" width="512" height="384" alt=""/></li>
<li><img src="images/2.jpg" width="512" height="384" alt=""/></li>
<li><img src="images/3.jpg" width="512" height="384" alt=""/></li>
<li><img src="images/4.jpg" width="512" height="384" alt=""/></li>
<li><img src="images/5.jpg" width="512" height="384" alt=""/></li>
<li><img src="images/6.jpg" width="512" height="384" alt=""/></li>
<li><img src="images/7.jpg" width="512" height="384" alt=""/></li>
</ul>
</div>
<img src="images/prev.png" width="50" height="50" alt="" class="prev"/>
<img src="images/next.png" width="50" height="50" alt="" class="next"/>
</div>
<!-- scroll end -->
<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
<script type="text/javascript">
$("#scroll img.prev").click(function() {
$(".list ul").prepend($(".list ul li:last"));
$(".list ul").css("left", "-512px");
$(".list ul").animate({"left" : "0px"}, 500);
});
$("#scroll img.next").click(function() {
$(".list ul").animate({"left" : "-512px"}, 500, function() {
$(".list ul").append($(".list ul li:first"));
$(".list ul").css("left", "0px");
});
});
var autoPlay = setInterval(function() {
$("#scroll img.next").click();
}, 2000);
$(".list ul").hover(function() {
clearInterval(autoPlay);
}, function() {
autoPlay = setInterval(function() {
$("#scroll img.next").click();
}, 2000);
});
</script>
</body>
</html>
相关文章推荐
- Js实现类似图片相册左右切换效果
- 图片左右循环切换功能的实现
- 网易新闻首页的实现,可以添加,移除标签,自动滚动图片,无限左右切换图片
- Android基于ImageSwitcher实现左右切换图片
- Android 基于ImageSwitcher实现的左右切换图片
- JS+CSS控制左右切换鼠标可控的无缝图片滚动代码
- xSlider 可左右、上下图片切换的无缝滚动效果
- 图片左右滚动无缝接JS代码实现
- Android:使用ViewPager实现左右滑动切换图片 (简单版)
- 图片轮播(左右切换)--JS原生和jQuery实现
- ViewFilpper、Gesture 实现图片左右滑动切换
- 使用viewpager嵌套实现上下左右滑动切换图片(IOS双向滚动翻页效果相同)
- JS实现图片滚动(无缝、平滑、上下左右滚动)效果
- javascript实现的简单图片左右切换
- 基于jQuery图片切换实现预加载插件,左右带控制
- 使用viewpager嵌套实现上下左右滑动切换图片(IOS双向滚动翻页效果相同)
- Android通过ViewPager实现左右滑动切换图片
- 使用ViewPager实现图片左右切换(有实心和空心和TextView随图片改变而改变)
- 原生js实现的图片左右切换
- jq图片左右无缝切换滚动,有定时切换。