亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

原生JS實(shí)現(xiàn)圖片左右輪播

 更新時(shí)間:2016年12月30日 11:43:33   作者:何問(wèn)起  
本文主要分享了原生JS實(shí)現(xiàn)圖片左右不停運(yùn)動(dòng)的完整示例代碼,可直接保存到HTML文檔打開可以查看效果。下面跟著小編一起來(lái)看下吧

本效果使用js實(shí)現(xiàn),當(dāng)圖片移動(dòng)到200像素后回到0像素再向右移動(dòng)200像素一直左右移動(dòng),不需要marquee標(biāo)簽。

完整的HTML代碼如下,保存到HTML文檔打開可以查看效果:

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <title>JS使圖片左右移動(dòng)_何問(wèn)起</title>
 <meta charset="utf-8" />
  <base target="_blank" />
  <style>a{color:blue;}</style>
</head>
<body>
  <p>mag:</p><input type="text" id="pos" /><br />
  <input type="button" onclick="move()" value="開始" />請(qǐng)點(diǎn)擊按鈕<br />
  <div style="position:relative;min-width:600px;min-height:120px;">
    <img id="img" style="position:absolute; left:100px;" src="http://hovertree.com/themes/hvtimages/hlogo.png" />
  </div>
  <div><a >查看代碼</a> <a >返回首頁(yè)</a> <a >更多特效</a></div>
  <script>
    var hovertreeStep, hovertreeTurn = true;
    function move() {
      var mag = parseInt(document.getElementById("img").style.left);
      document.getElementById("pos").value = mag;
      
      if (hovertreeTurn) {
        hovertreeStep = 1; hovertreeTurn = false;
      }
      if ( mag > 200) {
        hovertreeStep = -1;
      }
      if (mag < 1)
      {
        hovertreeStep = 1;
      }

      document.getElementById("img").style.left = (mag + hovertreeStep) + "px";
      window.setTimeout("move()", 50);
    }
  </script>
</body>
</html>

以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,同時(shí)也希望多多支持腳本之家!

相關(guān)文章

最新評(píng)論