动态图片JS动态效果

<style type="text/css">
<!--
.a{
border:10px #fcc solid;
}
.b{
border:none;
}
#pic{
width:500px;
height:300px;
overflow:hidden;
}
#pic0{
width:5000%;
height:300px;
}
-->
</style>
<body>
<div id="small">
<img src="" width="100" height="100" alt="1" />
<img src="" width="100" height="100" alt="2" />
<img src="" width="100" height="100" alt="3" />
<img src="" width="100" height="100" alt="4" />
</div>


<div id="pic">
<div id="pic0">
<span id="pic1"><img src="" width="500" height="300" alt="1" /><img src="" width="500" height="300" alt="2" /><img src="" width="500" height="300" alt="3" /><img src="" width="500" height="300" alt="4" /></span><span id="pic2"></span>
</div>
</div>
</body>
<script type="text/javascript">
var a = document.getElementById("small");
var b = a.getElementsByTagName("img");
var i = 0;
var pic = document.getElementById("pic");
var pic1 = document.getElementById("pic1");
var pic2 = document.getElementById("pic2");
window.οnlοad=function(){pic.scrollLeft = 0;return false;}
pic2.innerHTML = pic1.innerHTML;


function marquee()
{
if(pic2.offsetWidth-pic.scrollLeft == 0)
{
pic.scrollLeft = 500;
}
else
{
pic.scrollLeft+=500;
}
return false;
}


function _clear(n) {
return function (){
for (var j=0; j < b.length; j++)
{
if (n!=j)
{
b[j].className = "b";//不等于显示当前边框的时候其边框为没有;
}
}
//var out = setInterval(marquee,100);
function timeout(){clearInterval(out);return false;}//清除滚动函数
setTimeout(marquee,100);
}
}


function img()
{
b[i].className = "a";
if(i>b.length-2)
{
i=0;
}
else
{
i++;
}
setTimeout(_clear(i),2000);

}
setInterval(img,2000);
</script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值