为了账号安全,请及时绑定邮箱和手机立即绑定

left的值在网页里总是不对,用的别人的模板

left的值在网页里总是不对,用的别人的模板

var myLeft;        rePoint();    function rePoint() {         var myLeftNumber = parseInt((document.body.clientWidth - 1100) / 2);         if (myLeftNumber < 0) {             myLeftNumber = 0;         }        if (myLeft == myLeftNumber) {             return;         }        myLeft = myLeftNumber;     }  hidden.css({width:"1100px",height:"375px",top:"0","left":"0px","opacity":0,}); hidden.stop(true,true).animate({width:"1100px",height:"375px",top:"0",left:"0px",opacity:1,},timer); curr.stop(true,true).animate({width:"1100px",height:"375px",top:"0","left":"50%",opacity:1,},timer); next.stop(true,true).animate({width:"1100px",height:"375px",top:"0","left":"0px","opacity":0,},timer,function(){next.find("span").css("opacity",0); isMoving = false;}); //prev  -->  curr     prev中的图片li轮换到curr的位置      其他一次轮换 prev.find("span").css("opacity",0); $(".main_banner_box li").find("p").css({"bottom":"-50px"});//所有标题隐藏 prev.stop(true,true).animate({width:"1100px",height:"375px",left:"myLeft",top:0,opacity:1},timer,function(){ $(this).find("p").animate({"bottom":"0px"}); //当前这张图片的标题运动出来 }); index_2--; }else{ //执行next 操作 if(index_2+2>=len){ //index_2 3 4 hidden=$("#imgCard"+(index_2+2-len));// 0 1 }else{ //index_2 0 1 2 hidden=$("#imgCard"+(index_2+2));// 2 3 4 } prev.css("z-index","1"); next.css("z-index","5"); //点击next按钮  让next位置上的这张图片 层级最高 显示 curr.css("z-index","2"); hidden.css("z-index","1"); //当index_2自增,各图片往左运动效果 hidden.css({width:"1100px",height:"375px",top:"0px","left":"50%","opacity":0}); hidden.stop(true,true).animate({width:"1100px",height:"375px",top:"0px",opacity:1},timer); curr.stop(true,true).animate({width:"1100px",height:"375px",top:"0px",left:"0px",opacity:1},timer); //next  -->  curr     next中的图片li轮换到curr的位置      其他一次轮换 next.find("span").css("opacity",0); $(".main_banner_box li").find("p").css({"bottom":"-50px"});//所有标题隐藏 next.stop(true,true).animate({width:"1100px",height:"375px",left:"myLeft",top:0,opacity:1,margin:"0 auto"},timer,function(){ $(this).find("p").animate({"bottom":"0px"}); //当前这张图片的标题运动出来 }); prev.stop(true,true).animate({width:"1100px",height:"375px",left:"0px",top:"0px",opacity:0},timer,function(){ isMoving = false; });  index_2++; }
查看完整描述

1 回答

?
lxmhh3788029

TA贡献15条经验 获得超2个赞

我姑且一说哈,没有实际运行你的程序,只是扫了一下发现left:"myLeft"这样写是不对的,你的myLeft是一个变量,不用加引号,就写left:myLeft就行了

查看完整回答
反对 回复 2017-08-07
  • 1 回答
  • 0 关注
  • 1501 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信