图片切换(幻灯片模式)
2012-04-09 11:49
183 查看
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js"></script>
<style type="text/css">
body,ul,li { padding:0; margin:0}
ul,li { list-style:none}
.img-scroll { position:relative; width:440px;}
.img-scroll .prev,.img-scroll .next { position:absolute; display:block; width:50px; height:100px; background-color:#000;
top:0; color:#FFF; text-align:center; line-height:100px}
.img-scroll .prev { left:0}
.img-scroll .next { right:0}
.img-list { position:relative; width:320px; height:100px; margin-left:60px; overflow:hidden}
.img-list ul { width:9999px;}
.img-list li { float:left; display:inline; width:100px; margin-right:10px; height:100px; background-color:#BDBDDF; text-align:center; line-height:100px;}
</style>
</head>
<body>
<div class="img-scroll">
<span class="prev">prev</span>
<span class="next">next</span>
<div class="img-list">
<!-- <ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>-->
<ul><li id="li0" class="current">aaaa</li><li id="li1">bbbb</li><li id="li2">cccc </li><li id="li3">dddd</li></ul>
</div>
</div>
<script type="text/javascript">
function DY_scroll(wraper,prev,next,img,speed,or)
{
var wraper = $(wraper);
var prev = $(prev);
var next = $(next);
var img = $(img).find('ul');
var w = img.find('li').outerWidth(true);
var s = speed;
next.click(function()
{
img.animate({'margin-left':-w},function()
{
img.find('li').eq(0).appendTo(img);
img.css({'margin-left':0});
});
});
prev.click(function()
{
img.find('li:last').prependTo(img);
img.css({'margin-left':-w});
img.animate({'margin-left':0});
});
// if (or == true) //去掉注释就是自动滑动
// {
// ad = setInterval(function() { next.click();},s*1000);
// wraper.hover(function(){clearInterval(ad);},function(){ad = setInterval(function() { next.click();},s*1000);});
// }
}
DY_scroll('.img-scroll','.prev','.next','.img-list',3,true);
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.js"></script>
<style type="text/css">
body,ul,li { padding:0; margin:0}
ul,li { list-style:none}
.img-scroll { position:relative; width:440px;}
.img-scroll .prev,.img-scroll .next { position:absolute; display:block; width:50px; height:100px; background-color:#000;
top:0; color:#FFF; text-align:center; line-height:100px}
.img-scroll .prev { left:0}
.img-scroll .next { right:0}
.img-list { position:relative; width:320px; height:100px; margin-left:60px; overflow:hidden}
.img-list ul { width:9999px;}
.img-list li { float:left; display:inline; width:100px; margin-right:10px; height:100px; background-color:#BDBDDF; text-align:center; line-height:100px;}
</style>
</head>
<body>
<div class="img-scroll">
<span class="prev">prev</span>
<span class="next">next</span>
<div class="img-list">
<!-- <ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>-->
<ul><li id="li0" class="current">aaaa</li><li id="li1">bbbb</li><li id="li2">cccc </li><li id="li3">dddd</li></ul>
</div>
</div>
<script type="text/javascript">
function DY_scroll(wraper,prev,next,img,speed,or)
{
var wraper = $(wraper);
var prev = $(prev);
var next = $(next);
var img = $(img).find('ul');
var w = img.find('li').outerWidth(true);
var s = speed;
next.click(function()
{
img.animate({'margin-left':-w},function()
{
img.find('li').eq(0).appendTo(img);
img.css({'margin-left':0});
});
});
prev.click(function()
{
img.find('li:last').prependTo(img);
img.css({'margin-left':-w});
img.animate({'margin-left':0});
});
// if (or == true) //去掉注释就是自动滑动
// {
// ad = setInterval(function() { next.click();},s*1000);
// wraper.hover(function(){clearInterval(ad);},function(){ad = setInterval(function() { next.click();},s*1000);});
// }
}
DY_scroll('.img-scroll','.prev','.next','.img-list',3,true);
</script>
</body>
</html>
相关文章推荐
- js图片幻灯片模式切换代码
- jquery banner广告幻灯片图片轮播切换,模仿实现当当网滚动广告效果
- 纯js图片切换幻灯片代码
- KinSlideshow幻灯片插件 Jquery幻灯片 图片切换
- 详情页点击其中图片转换成幻灯片图文模式,图片对应文字。
- jquery 图片幻灯片切换效果代码(1/2)
- jquery的幻灯片图片切换效果代码分享
- JS 切换图片 (简单模式) 字体颜色,大小变化
- 十二星座图片缩放,夜间模式切换
- 图片幻灯片切换特效
- 18款jquery幻灯片图片切换 非常实用
- javascript实现图片切换的幻灯片效果源代码
- 18款 非常实用 jquery幻灯片图片切换
- 自动播放——幻灯片缓冲效果&&带Loading效果的图片切换&&移动效果(按轨迹移动)
- JS+Flash实现图片切换幻灯片效果
- JS案例练习:图片切换+切换模式
- 18款 非常实用 jquery幻灯片图片切换
- 各大门户网站Flash和JS实现的图片幻灯片切换特效代码文件下载:
- atitit.GUI图片非规则按钮跟动态图片切换的实现模式总结java .net c# c++ web html js