html5 css php,html5·css·php·js简单代码

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

这是一个图片左右滚动的代码

123

$(document).ready(function(){

var totalLiNum=$(*#slide ul*).children(*li*).length;

var trueWidth=totalLiNum*1010;

for(var i=1;i<=totalLiNum;i++){

$(*.icon*).append(*

s_off.png*);

}

$toLeft=function(){

var currentLeft=parseInt($(*#slide ul*).css(*left*).replace(*px*,**));

currentLeft=currentLeft-1010;

$(*#errorinfo*).text(currentLeft);

if((Math.abs(currentLeft))>=(trueWidth-1000)){

$(*#slide ul*).animate({left:0},1000);

}else{

$(*#slide ul*).animate({left:currentLeft},1000);

}

}

$(".toleft").click($toLeft);

$toRight=function(){

var currentLeft=parseInt($(*#slide ul*).css(*left*).replace(*px*,**));

currentLeft=currentLeft+1010;

$(*#errorinfo*).text(currentLeft +"++++"+trueWidth);

if(Math.abs(currentLeft)>=(trueWidth-1000)){

$(*#slide ul*).animate({left:currentLeft},1000);

}else{

$(*#slide ul*).animate({left:0},1000);

}

}

$(".toright").click($toRight);

$selectPic=function(){

var toLeft=$(this).attr(*index*)*1010-1010;

toLeft=toLeft*(-1);

$(*#slide ul*).animate({left:(toLeft+"px")},1000);

$(this).parent().find(*img*).attr(*src*,*images/s_off.png*);

$(this).find(*img*).attr(*src*,*images/s_on.png*);

}

$(".icon li").click($selectPic);

});

.warp{width:1000px;margin:0 auto;border: 1px solid #ccc;}

#slide{width:1000px;border:2px solid #ccc;margin:0 auto;overflow:hidden;}

#slide ul{list-style:none;width:9000px;position:relative;left:0px;margin:0;padding:0;}

#slide ul li{float:left;}

#slide ul li img{margin:30px;width:1000px;}

/*按钮*/

.btn-action{ position:relative;width:35px;height:50px;top: -130px; cursor: pointer;opacity:0.5;}

.btn-action:hover{opacity:1; }

.btn-action span{ text-indent: -99999px;display: block;}

.toleft{left:0; background:url(images/left.png);float: left;}

.toright{right:0;background:url(images/right.png);float: right;}

ul.icon{list-style:none;float:left;display:block;}

ul.icon li {width:32px;float:left;}

  • s01.jpg
  • s02.jpg
  • s03.jpg
左移
右移
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值