HTML轮播图失败原因,轮播图为什么实现不了

html>

focus

*{padding:0;margin: 0;}

li{list-style: none;}

#pic_box{

width: 500px;

height: 300px;

position: relative;

margin: 100px;

overflow: hidden;

}

#pic{

width: 2000px;

height: 300px;

position: absolute;

left:0;

top: 0;

}

#pic li{

width: 500px;

height: 300px;

float: left;

}

#pic li img{

width: 500px;

height: 300px;

}

#nav{

position: absolute;

left: 50%;

margin-left: -90px;

bottom: 40px;

}

#nav a{

float: left;

width: 20px;

height: 10px;

margin-left: 20px;

background: #ccc;

}

//如果你想更好的学会轮播,建议看这个课程http://www.imooc.com/learn/18

$(function(){

var count=0;

$("a").click(function(){

// $("#pic").css.left=-$(this).index()*500+'px';

//建议看JQuery的API文档,不要想当然应该是这样写,看看JQuery是否有这个方法或者属性

//http://www.codesocang.com/jq/jquery1.7.2.html

//建议分步骤测试,照你原来的代码,连count都没有获取到

count=$(this).index();

console.log(count);

$("#pic").animate({"marginLeft":-count*500});

})

setInterval(focus,1000);

//索引还需要判断,自己动手操作,自己理解

function focus(){

count++;

$("#pic").animate({"marginLeft":-count*500});

}

})

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值