JavaScript中實現無縫滾動、分享到側邊欄執行個體代碼,javascript執行個體

來源:互聯網
上載者:User

JavaScript中實現無縫滾動、分享到側邊欄執行個體代碼,javascript執行個體

廢話不多說,直接給大家貼代碼了,代碼解決一起問題!

下面一段代碼給大家介紹js無縫滾動執行個體代碼:

代碼如下所示:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>無標題文檔</title><style>*{margin:0px;padding:0px;}#div1{width:830px; height:166px; margin:50px auto;position:relative;background:white;overflow:hidden;}#div1 ul li{float:left; width:174px; height:166px; list-style:none;}ul{position:absolute;}</style><script>window.onload=function(){var oDiv=document.getElementById('div1');var oUl=oDiv.getElementsByTagName('ul')[0];var aLi=oUl.getElementsByTagName('li');var speed=3oUl.innerHTML=oUl.innerHTML+oUl.innerHTML;oUl.style.width=aLi[0].offsetWidth*aLi.length+'px';function move (){if(oUl.offsetLeft<-oUl.offsetWidth/2){oUl.style.left='0';}if(oUl.offsetLeft>0){oUl.style.left=-oUl.offsetWidth/2+'px';}oUl.style.left=oUl.offsetLeft+speed+'px';};var timer=setInterval(move,30);oDiv.onmouseover=function(){clearInterval(timer);};oDiv.onmouseout=function(){timer=setInterval(move,30);}document.getElementsByTagName('a')[0].onclick=function(){speed=-3;};document.getElementsByTagName('a')[1].onclick=function(){speed=3;};};</script></head><body><a href="javascipt:;">向左走</a><a href="javascipt:;">向右走</a><div id="div1"><ul><li><img src="images/b01.jpg" /></li><li><img src="images/b02.jpg" /></li><li><img src="images/b03.jpg" /></li><li><img src="images/b04.jpg" /></li><li><img src="images/b05.jpg" /></li></ul></div></body></html>

分享到側邊欄js代碼如下所示:

代碼如下所示:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>無標題文檔</title><style>#div1{width:100px; height:150px; background:#0F0; position:absolute; left:-100px;}#div1 span{position:absolute; width:20px; height:60px; line-height:20px; background:#00F; right:-20px; top:50px;}</style><script>window.onload=function(){var oDiv=document.getElementById('div1');oDiv.onmouseover=function(){startMove(10,0);}oDiv.onmouseout =function(){startMove(-10,-100);}}var timer=null;function startMove(speed,locall){var oDiv=document.getElementById('div1');clearInterval(timer);timer=setInterval(function(){if(oDiv.offsetLeft==locall){clearInterval(timer);}else{oDiv.style.left=oDiv.offsetLeft+speed+'px'; }},30);}</script></head><body><div id="div1"><span>分享到</span></div></body></html>

以上所述是小編給大家介紹的JavaScript中實現無縫滾動、分享到側邊欄執行個體代碼,代碼簡單易懂,有疑問歡迎給我留言,小編及時給您回覆!

您可能感興趣的文章:
  • 徹底搞懂JS無縫滾動代碼
  • js 實現無縫滾動 相容IE和FF
  • 走馬燈效果代碼js appendChild實現的無縫滾動
  • Jquery與JS兩種方法仿twitter/新浪微博 高度自適應無縫滾動實現代碼
  • jcarousellite.js 基於Jquery的圖片無縫滾動外掛程式
  • 部落格側邊欄模組跟隨捲軸滑動固定效果的實現方法(js+jquery等)
  • div+css+js實現無縫滾動類似marquee無縫滾動相容firefox
  • js向上無縫滾動,網站公告效果 具體代碼
  • javascript實現動態側邊欄代碼
  • JS圖片無縫、平滑滾動代碼
  • JS運動架構之分享側邊欄動畫執行個體

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.