A Pen by Bikrant Giri on CodePen.
Created
March 17, 2017 07:16
-
-
Save l3ikrant/510b692e0c0f20b650e638de0323f636 to your computer and use it in GitHub Desktop.
Responsive News Ticker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="ticker"> | |
| <li><a href="http://www.bikrantgiri.com.np" title="">ईमान्दार बन्दा हेपिने प्रवृति विरुद्ध 'निर्भय': निखिल, चैत्र ११ मा रिलिजको तयारी</a></li> | |
| <li><a href="http://www.bikrantgiri.com.np" title="">रमाइलो दोहोरी गीत 'सेक्सी देखिन्छौ' को रेकर्डिङ सम्प्पन</a></li> | |
| <li><a href="http://www.bikrantgiri.com.np" title="">प्रबासमा रहेर पनि गीत संगीत लागिरहेको छु : चर्चित गायक ओली</a></li> | |
| <li><a href="http://www.bikrantgiri.com.np" title="">मेलिना राईको आवाजमा लाहाचोकलाई चिनाउने गीत सार्बजनिक</a></li> | |
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(document).ready(function() { | |
| var block_arr = $('.ticker li a').map(function() { return $(this).get(0);}).toArray(); | |
| var ticker_item = $(block_arr[0]); | |
| $(".ticker").html(ticker_item); | |
| var ticker_width = $(".ticker").width(); | |
| var text_x = ticker_width; | |
| scroll_ticker = function() { | |
| text_x--; | |
| ticker_item.css("left", text_x); | |
| if (text_x < -1 * ticker_item.width()) { | |
| ticker_item = $(block_arr[(block_arr.indexOf(ticker_item.get(0)) + 1 == block_arr.length) ? 0 : block_arr.indexOf(ticker_item.get(0)) + 1]); | |
| ticker_item.css("left", text_x); | |
| $(".ticker").html(ticker_item); | |
| text_x = ticker_width; | |
| } | |
| } | |
| var timer = setInterval(scroll_ticker, 15); | |
| $('.ticker').hover(function(ev){ | |
| clearInterval(timer); | |
| }, function(ev){ | |
| timer = setInterval( scroll_ticker, 15); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body{ | |
| font-family: 'Ek Mukta', sans-serif; | |
| font-size: 16px; | |
| line-height: 120%; | |
| background: #f3f3f3; | |
| padding: 5%; | |
| } | |
| .ticker { | |
| position: relative; | |
| padding: 10px 10px; | |
| padding-left: 30px; | |
| background: #FFF; | |
| overflow: hidden; | |
| a{ | |
| position: relative; | |
| top: 0; | |
| white-space: nowrap; | |
| width: auto; | |
| color: #333; | |
| text-decoration: none; | |
| } | |
| &:before{ | |
| content: 'ताजा समाचार :'; | |
| position: absolute; | |
| left: 0; | |
| top: 0; | |
| display: block; | |
| padding: 10px 10px; | |
| background: #242526; | |
| z-index: 9; | |
| color: #FFF; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment