Jquery实现简单的图片滚动效果



<!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="js/jquery-1.9.1.js"></script>
<style type="text/css">
 body,ul,li { padding:0; margin:0}
 ul,li { list-style:none}
.person_pic{ width:72%; height:auto; margin-top:18%; margin-left:28%;}
.per-pic-scroll {height:200px; position:relative;margin-top:5%; margin-left:10px;}
.per-pic-scroll .pre,.per-pic-scroll .next { 
position:absolute; display:block; width:35px; height:50px; 
background-color:#999999;top:23px; color:#FFF; text-align:center; 
line-height:50px;}
.per-pic-scroll .pre { left:16px}
.per-pic-scroll .next { right:50px}
.img-list { position:relative; width:78%; height:150px; margin-left:60px; overflow:hidden}
.img-list ul { width:200%;} //这里一定要大点
.img-list li { float:left; display:inline; width:135px; margin-right:10px; height:150px; background-color:#BDBDDF; text-align:center; line-height:100px;}
.img-list li img{width:135px; height:150px;}
.per-pic-scroll a{ text-decoration:none; }
</style>

<script type="text/javascript">
	function Per_pic_scroll(){ 
	  var pre_person , next_person , image , wid;
	  pre_person = $(".pre") , next_person = $(".next") , image = $(".img-list").find('ul');
	  wid = $(".img-list").find('ul').find("li").outerWidth(false);

	  next_person.click(function(){
			image.animate({'margin-left':-wid},function()
					  {
					   image.find('li').eq(0).appendTo(image);
					   
					   image.css({'margin-left':0});
					   });
			});
	  pre_person.click(function(){

				image.find('li:last').prependTo(image);

				image.css({'margin-left':-wid});

				image.animate({'margin-left':0});

				});
	}
$(function(){
	
	 Per_pic_scroll();

})
</script>
</head>

<body>

 <div class="person_pic">
		<div class="per-pic-scroll">
		
			 <span class="pre"><a href="#" οnclick="return false"><</a></span>
			 <span class="next"><a href="#" οnclick="return false">></a></span>
			 <div class="img-list">
				 <ul>
					 <li>1</li>
					 <li>2</li>
					 <li>3</li>
					 <li>4</li>
					 <li>5</li>
					 <li>6</li>
					 <li>7</li>
					 <li>8</li>
					 <li>9</li>
				</ul>
		  </div>
	  </div>
  </div>
</body>
</html>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值