jquery seamless scroll up implementation code_jquery
May 16, 2016 pm 05:39 PM
Seamless scrolling
JS part
$(function (){
var $this = $(".renav");
var scrollTimer;
$this.hover(function(){
clearInterval(scrollTimer);
},function (){
scrollTimer = setInterval(function(){
scrollNews( $this );
}, 2000 );
}).trigger("mouseout");
});
function scrollNews(obj){
var $self = obj.find("ul:first");
var lineHeight = $self.find("li:first").height();
$self.animate({ "margin-top" : -lineHeight "px" },600 , function(){
$self.css({"margin-top":"0px"}).find( "li:first").appendTo($self);
})
}
HTML part
<style type="text/css">
.renav{
width :200px;
height:150px;
line-height:21px;
overflow:hidden;
background:#FFFFFF;
}
.renav li{
height: 21px;
}
</style>
<div class="renav">
<ul style="margin-top: 0px;">
< li><a>Roche</a></li>
<li><a>Resound</a></li>
<li>< a>Not added1</a></li>
<li><a>Not added2</a></li>
<li><a>Not added 3</a></li>
<li><a>Not added 4</a></li>
<li><a>Siemens</a> </li>
<li><a>OMRON</a></li>
</ul>
</div>
Copy code The code is as follows:
$(function (){
var $this = $(".renav");
var scrollTimer;
$this.hover(function(){
clearInterval(scrollTimer);
},function (){
scrollTimer = setInterval(function(){
scrollNews( $this );
}, 2000 );
}).trigger("mouseout");
});
function scrollNews(obj){
var $self = obj.find("ul:first");
var lineHeight = $self.find("li:first").height();
$self.animate({ "margin-top" : -lineHeight "px" },600 , function(){
$self.css({"margin-top":"0px"}).find( "li:first").appendTo($self);
})
}
HTML part
Copy code The code is as follows:
<style type="text/css">
.renav{
width :200px;
height:150px;
line-height:21px;
overflow:hidden;
background:#FFFFFF;
}
.renav li{
height: 21px;
}
</style>
<div class="renav">
<ul style="margin-top: 0px;">
< li><a>Roche</a></li>
<li><a>Resound</a></li>
<li>< a>Not added1</a></li>
<li><a>Not added2</a></li>
<li><a>Not added 3</a></li>
<li><a>Not added 4</a></li>
<li><a>Siemens</a> </li>
<li><a>OMRON</a></li>
</ul>
</div>
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

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Tips and methods to achieve seamless scrolling effect with CSS

How to use CSS to create a seamless scrolling text carousel effect

Methods and techniques for achieving seamless scrolling news through pure CSS

How to use Vue to achieve seamless scrolling advertising effects

How to use CSS to create a seamless scrolling image carousel effect

How to use CSS to create a seamless scrolling image display bar effect

How to use CSS to create a seamless scrolling text display effect.

How to achieve seamless scrolling news notifications using HTML, CSS and jQuery
