html js文字左右滾動外掛程式

來源:互聯網
上載者:User

標籤:

自己寫過很多外掛程式,但都是直接嵌入在了工程裡,從來沒有拿出來單獨封裝成一個檔案過,這是第一次,希望是一個良好的開端。

 

一個文字過長而可以左右滾動的外掛程式

 1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4     <meta charset="UTF-8"> 5     <title>Document</title> 6 </head> 7 <style> 8     div{ 9         width:200px;10         overflow:hidden;11     }12     span{13         display: inline-block;14         word-break:keep-all;           /* 不換行 */15         white-space:nowrap;          /* 不換行 */16         width: auto;17         text-align: right;18     }19 </style>20 <body>21     <div class="font-scroll"><span>剪影的你輪廓太好看,忍住眼淚才敢細看</span></div>22     <div class="font-scroll"><span>剪影的你輪廓太好看,忍住眼淚才敢細看</span></div>23     <div class="font-scroll"><span>剪影的你輪廓太好看,忍住眼淚才敢細看</span></div>24 </body>25 <script src="./jquery.min.js"></script>26 <script src="./font-scroll.js"></script>27 </html>
/**Magin 2016/8/28 */$(function(){    function fontLeft(e){        $(e).children(‘span‘).css(‘magin-left‘,‘0px‘)         $(e).children(‘span‘).animate({                marginLeft:parseFloat($(e).css(‘width‘))-parseFloat($(e).children(‘span‘).css(‘width‘))-12            },2000,"linear",function(){                fontRight(e);            })    }    function fontRight(e){        $(e).children(‘span‘).css(‘magin-left‘,parseFloat($(e).css(‘width‘))-parseFloat($(e).children(‘span‘).css(‘width‘)));        $(e).children(‘span‘).animate({                marginLeft:‘12px‘            },2000,"linear",function(){                fontLeft(e);            })    }    $(‘.font-scroll‘).each(function(){if($(this).children(‘span‘).css(‘width‘)>$(this).css(‘width‘)){        fontLeft(this)        }    })})

 

html 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.