以下是 jQuery上下间歇文字滚动js代码 的示例演示效果:
部分效果截图:
HTML代码(index.html):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery上下间歇文字滚动</title>
</head>
<body>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<style type="text/css">
*{margin:0;padding:0;list-style-type:none;}
a,img{border:0;}
body{font:12px/180% Arial,Lucida,Verdana,"宋体",Helvetica,sans-serif;color:#333;background:#fff;}
.scrolltext{width:230px;height:287px;overflow:hidden;background:url(images/123aafa.png) no-repeat;}
/* quotation */
#quotation{width:190px;height:227px;overflow:hidden;margin:44px auto 0 auto;}
#quotation li{line-height:28px;padding-bottom:35px;}
#quotation li .a-r{text-align:right;}
#quotation li span{color:#999;margin:0 0 0 10px;}
</style>
<br>
<div class="scrolltext">
<div id="quotation">
<ul>
<li>
<p>jquery图片大小尺寸调整插件,自适应容器图片垂直居中,自定义图片大小尺寸宽度和高度...</p>
<p class="a-r"><a href="#" class="stress">jquery文字滚动</a><span>2012-07-10</span></p>
</li>
<li>
<p>jquery jCoverflip图片插件制作图片水平滑动展示,依次放大缩小图片缩放翻转展...</p>
<p class="a-r"><a href="#" class="stress">jquery文字滚动</a><span>2012-07-09</span></p>
</li>
<li>
<p>jquery图片插件制作图片等比列缩放层叠样式,图片叠加展示。点击层叠最上层...</p>
<p class="a-r"><a href="#" class="stress">jquery文字滚动</a><span>2012-07-10</span></p>
</li>
<li>
<p>jquery图片放大插件制作一个当鼠标滑过图片,图片按等比例缩放放大效果...</p>
<p class="a-r"><a href="#" class="stress">jquery文字滚动</a><span>2012-07-09</span></p>
</li>
</ul>
</div>
</div>
<script type="text/javascript">
$(function(){
var scrtime;
$("#quotation").hover(function(){
clearInterval(scrtime);
},function(){
scrtime = setInterval(function(){
var $ul = $("#quotation ul");
var liHeight = $ul.find("li:last").height();
$ul.animate({marginTop : liHeight + 35 + "px"},1000,function(){
$ul.find("li:last").prependTo($ul)
$ul.find("li:first").hide();
$ul.css({marginTop:0});
$ul.find("li:first").fadeIn(1000);
});
},4000);
}).trigger("mouseleave");
});
</script>
</body>
</html>