JS實(shí)現(xiàn)的新聞列表自動(dòng)滾動(dòng)效果示例
本文實(shí)例講述了JS實(shí)現(xiàn)的新聞列表自動(dòng)滾動(dòng)效果。分享給大家供大家參考,具體如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style type="text/css"> #box{width:260px;height:100px;margin:0 auto;border:2px solid red;overflow: hidden} ul{padding:0;margin:0;list-style: none;overflow: hidden} ul li{height:24px;line-height: 24px;padding-left:10px;} a{text-decoration: none;color:#000;} a:hover{color:#f00} </style> </head> <body> <div id="box"> <ul id="con1" onMouseOut="Up()" onMouseOver="Stop()"> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >1,課程html</a> </li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >2,課程css</a> </li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >3,課程js</a> </li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >4,課程jquery</a> </li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >5,課程html5</a> </li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >6,課程css3</a> </li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >7,課程hp</a> </li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >8,課程bpootstrap</a> </li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >9,課程apicloud</a> </li> </ul> <ul id="con2"></ul> </div> </body> <script type="text/javascript"> var box=document.getElementById("box"); var con1=document.getElementById("con1"); var con2=document.getElementById("con2"); var s=document.getElementsByTagName("a"); var speed=50; con2.innerHTML=con1.innerHTML; function ScrollUp(){ if( box.scrollTop>=con1.scrollHeight){ box.scrollTop=0; }else box.scrollTop++; } var i=setInterval("ScrollUp()",speed); function Stop(){ clearInterval(i); } function Up(){ i=setInterval("ScrollUp()",speed); } </script> </html>
這里使用在線(xiàn)HTML/CSS/JavaScript代碼運(yùn)行工具:http://tools.jb51.net/code/HtmlJsRun測(cè)試上述代碼,可得如下運(yùn)行效果:
更多關(guān)于JavaScript相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《JavaScript切換特效與技巧總結(jié)》、《JavaScript查找算法技巧總結(jié)》、《JavaScript錯(cuò)誤與調(diào)試技巧總結(jié)》、《JavaScript數(shù)據(jù)結(jié)構(gòu)與算法技巧總結(jié)》、《JavaScript遍歷算法與技巧總結(jié)》及《JavaScript數(shù)學(xué)運(yùn)算用法總結(jié)》
希望本文所述對(duì)大家JavaScript程序設(shè)計(jì)有所幫助。
相關(guān)文章
countup.js實(shí)現(xiàn)數(shù)字動(dòng)態(tài)疊加效果
這篇文章主要為大家詳細(xì)介紹了countup.js實(shí)現(xiàn)數(shù)字動(dòng)態(tài)疊加效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-10-10layui在form表單頁(yè)面通過(guò)Validform加入簡(jiǎn)單驗(yàn)證的方法
今天小編就為大家分享一篇layui在form表單頁(yè)面通過(guò)Validform加入簡(jiǎn)單驗(yàn)證的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-09-09js拖動(dòng)div 當(dāng)鼠標(biāo)移動(dòng)時(shí)整個(gè)div也相應(yīng)的移動(dòng)
要拖動(dòng)的div為最外層的div,這段代碼對(duì)顯示對(duì)話(huà)框的頭部綁定鼠標(biāo)監(jiān)聽(tīng)事件,當(dāng)鼠標(biāo)移動(dòng)時(shí),整個(gè)div也相應(yīng)的移動(dòng),具體的實(shí)現(xiàn)如下,感興趣的朋友可以參考下2013-11-11webpack實(shí)現(xiàn)靜態(tài)資源緩存的方法
本文主要介紹了webpack實(shí)現(xiàn)靜態(tài)資源緩存的方法,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-08-08uniapp介紹與使用以及小程序?qū)崟r(shí)獲取視頻播放時(shí)間
這篇文章主要給大家介紹了關(guān)于uniapp介紹與使用以及小程序?qū)崟r(shí)獲取視頻播放時(shí)間的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用uniapp具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2023-02-02