首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

js 怎样控制图片的滑动解决思路

2012-03-14 
js 怎样控制图片的滑动html xmlnshttp://www.w3.org/1999/xhtmlhead runatservertitle无标题

js 怎样控制图片的滑动
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>无标题页</title>
   
  <script type="text/javascript">
  var add=1.2;  
  var count=0;  
  var countT=0;
  var act;
  function over(s,nMax){
  var obj=document.getElementById(s);
  var h = parseInt(obj.offsetHeight);
  if (h+count < nMax){
  obj.style.height = (h + count)+"px";
  clearTimeout(act);
  act = setTimeout("over('"+s+"',"+nMax+")", 4);
  count +=add;
  }
  else{
  obj.style.height = nMax+"px";
  count=0;
  }
  }

  function out(s,nMin){
  var obj=document.getElementById(s);
  var h = parseInt(obj.offsetHeight);
  if (h-count > nMin){
  obj.style.height = (h - count)+"px";
  clearTimeout(act);
  act = setTimeout("out('"+s+"',"+nMin+")", 10);
  count +=add;
  }
  else{
  obj.style.height = nMin+"px";
  count=0;
  }
  }
   
   
  </script>
   
  <style type="text/css">
  .style1
  {
  width: 24%;
  height: 25px;
  }
  .style2
  {
  width: 83px;
  }
  </style>
   
</head>
<body>
  <form id="form1" runat="server">
   
  </form>

  <div id="mytd" onmouseover="over('mytd',200);" onmouseout="out('mytd',20);" style="height: 20px; background: #ff0066; width: 144px;"> 
  <img src="img/d_right_nav_p1.jpg" style="height: 21px; width: 145px" />  
  </div>
   
   

</body>
</html>

把上面那个div的滑动 改编成图片的互动怎么办

[解决办法]
jquery里去找吧
[解决办法]
把上面那个div的滑动 改编成图片的互动怎么办
-----
是互动?还是滑动?
互动,就找别的专门互动的代码,互动和滑动字面上相差很远,不知效果有什么相似(没看楼主代码)。
滑动的话,只要把你想要的图片作为那个DIV的背景图就可以了,css里设一下那个DIV的background。
[解决办法]
scrollLeft或是scrollTop


用个定时器跑就可以了

热点排行