Home > Web Front-end > JS Tutorial > body text

Introducing a jquery special effect - seamless upward scrolling list

零下一度
Release: 2017-06-17 17:08:14
Original
2087 people have browsed it

Effect presentation

The entire list moves up the height of an item at the set time interval

html structure:

  <div class="slide-title">
        <span>title1</span>
        <span>title2</span>
        <span>title3</span>
   </div>
   <div class="slide-container"><!--css设置时,注意高度是显示多少个item,如:item的高度是30px,显示3个,高度则是 3*30 = 90px -->
        <ul class="slide-list js-slide-list">
            <li class="odd"><span>item1</span><span>item1</span><span>item1</span></li>
            <li class="even"><span>item2</span><span>item2</span><span>item2</span></li>
            <li class="even"><span>item2</span><span>item2</span><span>item2</span></li>
        </ul>
   </div>
Copy after login

Implementation idea:
Get js-slide -The height of the first li element under the list, its height or marginTop will be animated changed from present to nonexistent, the code is as follows:

var doscroll = function(){    var $parent = $(&#39;.js-slide-list&#39;);    var $first = $parent.find(&#39;li:first&#39;);    var height = $first.height();    $first.animate({        height: 0   //或者改成: marginTop: -height + &#39;px&#39;        }, 500, function() {// 动画结束后,把它插到最后,形成无缝        $first.css(&#39;height&#39;, height).appendTo($parent);       // $first.css(&#39;marginTop&#39;, 0).appendTo($parent);    });};setInterval(function(){doscroll()}, 2000);
Demo1Demo2
Copy after login

The above is the detailed content of Introducing a jquery special effect - seamless upward scrolling list. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template