| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 4812 人关注过本帖
标题:淘宝轮播js 求助大神!!!!!
只看楼主 加入收藏
炎之言
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-3-9
收藏
 问题点数:0 回复次数:0 
淘宝轮播js 求助大神!!!!!
<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus&reg;">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <style>
  body{width:100%;overflow-x:hidden;}
  #lun{background:red;position:absolute;}
  #lun img{float:left;}
  #bian{position:relative;margin:50px auto 0;background:yellow;overflow:hidden;}
  </style>
  <title>Document</title>
  <script>
  window.onload=function(){
      var a=0;
  var odiv1=document.getElementById('lun');
  var obian=document.getElementById('bian');
  var oli=odiv1.getElementsByTagName('img');
  odiv1.style.width=oli[0].offsetWidth*oli.length+'px';
  obian.style.width=oli[0].offsetWidth+'px';
  obian.style.height=oli[0].offsetHeight+10+'px';
  setInterval(function(){
      if(odiv1.offsetLeft<-oli[0].offsetWidth*oli.length){odiv1.style.left=0+'px';clearInterval(time);}
      else{a=a+oli[0].offsetWidth;han(-a);}
  },1000)
  }
  var timer=null;
  function han(it){
  var odiv1=document.getElementById('lun');
 clearInterval(timer);
  timer=setInterval(function(){
  var ispeed=(it-odiv1.offsetLeft)/8;
  ispeed=ispeed>0?Math.ceil(ispeed):Math.floor(ispeed);
  if(it==odiv1.offsetLeft){clearInterval(timer);}
  else{odiv1.style.left=odiv1.offsetLeft+ispeed+'px';}
  },30)
  }
  </script>
 </head>
 <body>
 <div id="bian">
 <div id="lun">
 <img src="e1.jpg" />
 <img src="e2.jpg" />
 <img src="e3.jpg" />
 <img src="e4.jpg" />
 </div></div>
 </body>
</html>


[此贴子已经被作者于2016-3-9 21:52编辑过]

搜索更多相关主题的帖子: content relative position absolute background 
2016-03-09 21:50
快速回复:淘宝轮播js 求助大神!!!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016986 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved