Js achieves vertical text scrolling and mouse hovering, js hovering
This article introduces the vertical scrolling Effect of text, mainly using the setInterval (function () {}, time); method. The content is as follows:
HTML layout:
<Ul class = "recommend-info"> <li> <span class = "push"> recommendation </span> <a href = "javascript:;"> 1 high-end community, classic apartment, rare opportunity, transient! For only 0.66 million! </A> <span class = "htype"> Room 3, Room 2, Hall 1, Wei 0.66 million ㎡ </span> </li> <span class = "push"> recommended </span> <a href = "javascript :; "> 2 high-end community, classic apartment type, rare opportunity, fleeting! For only 0.66 million! </A> <span class = "htype"> Room 3, Room 2, Hall 1, Wei 0.66 million ㎡ </span> </li> <span class = "push"> recommended </span> <a href = "javascript :; "> 3 high-end community, classic apartment type, rare opportunity, transient! For only 0.66 million! </A> <span class = "htype"> Room 3, Room 2, Hall 1, Wei 0.66 million ㎡ </span> </li> <span class = "push"> recommended </span> <a href = "javascript :; "> 4 high-end community, classic apartment type, rare opportunity, fleeting! For only 0.66 million! </A> <span class = "htype"> 0.66 million rooms, 2 rooms, 1 bathroom, 120 ㎡ </span> </li> </ul>
CSS style:
<style> .recommend-info { width: 630px; height: 42px; padding: 0 10px; margin-top: 12px; margin-bottom: 18px; border: 1px dashed #DFDFDF; overflow: hidden; } .recommend-info li { overflow: hidden; font-size: 14px; line-height: 42px; } .recommend-info li .push { float: left; display: inline-block; width: 18px; height: 17px; margin-top: 12px; margin-right: 10px; background: #D95B4E; font-size: 12px; color: #fff; text-align: center; line-height: 17px; } .recommend-info li a { float: left; color: #333; } .recommend-info li a:hover { color: #da5c4f; } .recommend-info li .htype { float: right; color: #999; }</style>
JS script:
<Script> // continually append the first new append to function vscroll () {var frtEle = $ ('. recommend-info li: first '); frtEle. animate ({'margintop':-$ ('. recommend-info li '). height ()}, 500, function () {frtEle.css ('margintop ', 0); $ ('. recommend-info '). append (frtEle) ;});} var startInterval = setInterval (vscroll, 3000); // hover the cursor over $ ('. recommend-info li '). hover (function () {clearInterval (startInterval) ;}, function () {startInterval = setInterval (vscroll, 3000) ;}); </script>
The above is all the content of this article. Thank you for your attention!
Articles you may be interested in:
- Navigation bar that is dynamically tumble when the mouse is hovering in javascript
- Javascript implements automatic circular scrolling of text or images inside the div
- A simple JS mouse hover effect method
- Scroll the JavaScript code to the left
- Js implements the method of scrolling text description when hovering over an image
- How to Use js to implement text link mouse hover prompts for animation Effects
- Javascript imitation Sina game channel mouse hover show sub menu Effect