簡單jQuery網站公告逐行輪播效果

來源:互聯網
上載者:User

標籤:bsp   網站   top   ati   out   簡單   實現   seo   ndt   

CSS樣式:

<style>*
{margin:0; padding:0;}ul,li{list-style:none;}a{text-decoration:none;}img{border:none; vertical-align:top;}#notice{width:500px; height:40px; position:relative; overflow:hidden; margin:50px auto; border:1px solid #CCC;}#notice ul{position:absolute;left:0; top:0;}#notice ul li{width:100%; height:40px; line-height:40px; text-indent:20px;}</style>
HTML結構:

<
div id="notice"> <ul> <li><a href="#">就讓那一切成流水把那往事</a></li> <li><a href="#">把那往事當作一場宿醉</a></li> <li><a href="#">明日的酒杯莫再要裝著昨天的傷悲</a></li> </ul></div>
JS代碼實現(需先匯入jquery庫檔案):  

function
moveTop(obj,num,tag1,tag2){ //容器元素 滾動行數 父元素 子項目 var iH = $(obj).find(tag2).height(); $(obj+tag1).css(‘height‘,iH * $(obj).find(tag2).length); $(obj).find(tag1).animate({‘top‘:iH*num},500,function(){ $(this).css({top:0}).find(‘tag2:first‘).appendTo(this); });}var timer = null;timer = setInterval(‘moveTop(".notice",1,"ul","li")‘,3000); //自動輪播$(".notice").hover(function(){ //滑鼠移入時停止自動輪播(滑鼠移入移出事件也可用mouseover和mouseout來實現) clearInterval(timer); },function(){ timer = setInterval(‘moveTop(".notice",1,"ul","li")‘,3000); //滑鼠移出時繼續自動輪播});

 

 

 

 

簡單jQuery網站公告逐行輪播效果

聯繫我們

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