麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > JavaScript > 正文

JavaScript中實現(xiàn)無縫滾動、分享到側(cè)邊欄實例代碼

2019-11-20 10:17:19
字體:
供稿:網(wǎng)友

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

下面一段代碼給大家介紹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>

分享到側(cè)邊欄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中實現(xiàn)無縫滾動、分享到側(cè)邊欄實例代碼,代碼簡單易懂,有疑問歡迎給我留言,小編及時給您答復(fù)!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 1级黄色毛片 | 黄色片网站在线免费观看 | 亚洲日色| 日韩黄色片免费看 | 国产一级做a | 国产噜噜噜噜久久久久久久久 | 国产精品午夜未成人免费观看 | www.guochanav.com| 亚洲福利视| 久久精品国产久精国产 | 国产精品区一区二区三区 | 中文字幕观看 | 深夜视频福利 | 精品一区免费 | 色阁五月 | 黄色免费小网站 | 日韩毛片在线看 | 久草在线高清视频 | 日本黄色免费片 | 欧美18videos性处按摩 | 一本一道久久久a久久久精品91 | 国产精品视频二区不卡 | 国产午夜精品一区二区三区四区 | 在线观看免费毛片视频 | 欧美 videos粗暴 | 久久精品国产一区二区电影 | 在火车上摸两乳爽的大叫 | 色综合久久99 | 精品午夜久久 | 午夜视频福利 | 国产精品视频一区二区三区四 | 欧美人与禽性xxxxx杂性 | 亚洲第一成人在线观看 | 制服丝袜日日夜夜 | 久久久久北条麻妃免费看 | 精品久久中文字幕 | 成人精品久久久 | 粉嫩蜜桃麻豆免费大片 | 亚洲精品wwww | 性大片1000免费看 | 国产免费区 |