查看效果:向上滾動代碼
<style>
div { font-size:12px; }
</style>
<div id="mq" style="width:100%;height:70px;overflow:hidden" onmouseover="iScrollAmount=0"
onmouseout="iScrollAmount=1">
向上滾動代碼 <br>
向上滾動代碼<br>
向上滾動代碼<br>
</div>
<script>
var oMarquee = document.getElementById("mq"); //滾動對象
var iLineHeight = 42; //單行高度,像素
var iLineCount = 7; //實際行數(shù)
var iScrollAmount = 1; //每次滾動高度,像素
function run() {
oMarquee.scrollTop += iScrollAmount;
if ( oMarquee.scrollTop == iLineCount * iLineHeight )
oMarquee.scrollTop = 0;
if ( oMarquee.scrollTop % iLineHeight == 0 ) {
window.setTimeout( "run()", 2000 );
} else {
window.setTimeout( "run()", 50 );
}
}
oMarquee.innerHTML += oMarquee.innerHTML;
window.setTimeout( "run()", 2000 );
</script>
更多信息請查看IT技術(shù)專欄