js圖片向右輪轉效果代碼

來源:互聯網
上載者:User
提示:您可以先修改部分代碼再運行

<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>圖片箱一</title><!--樣式設定--><style type="text/css">body{margin:0;padding:0;}#imgB{border:1px solid #dddddd;margin:20px;overflow:hidden;width:600px;height:300px;position:relative;} #imgBox{position:absolute;}</style><!--js代碼--><script type="text/javascript">//初始化var n=0;var x = 2;//移到函數function mv(){var imgBox = document.getElementById('imgBox');//擷取對象imgBox.style.left = n+"px";//設定styl.left的值n=n-x;//累計改變x的值才能使圖片有移到的效果//這裡圖片的高度為300px,寬度為600px。先想做滾動等到最後一個完全顯示,即n=-1200時向相反的方向移動,到達第一個時再像左移動if(n<= -1200){x=-x;}else if(n>=0){x=-x;}//迴圈,移到的速度可以通過改變這裡的20,或者改變外部x的值實現快慢控制setTimeout(mv,20);}</script></head><body onload="mv()"><!--圖片箱--><div id="imgB"><!--內圖片框--><table id="imgBox" cellspacing="0" cellpadding="0" border="0"><td></td><td></td><td></td></table></div></body></html></td> </tr></table>
提示:您可以先修改部分代碼再運行

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.