HTML文字上下循环滚动代码


<html>
    <head>
        <meta charset="UTF-8">
        <title>title>
    head>
    <body>
<div id="hdemo" style="height:200px;overflow:hidden;">
<div id="indemo" style="height:200%;">
<div id="hdemo1">
第一行字<br />
第二行字
div>
<div id="hdemo2">div>
div>
div>
body>
<script type="text/javascript">
speed = 100; //数字越大滚得越慢
var htab = document.getElementById("hdemo");
var htab1 = document.getElementById("hdemo1");
var htab2 = document.getElementById("hdemo2");
htab2.innerHTML = htab1.innerHTML;
htab.scrollTop = htab1.offsetHeight;
function Marquee(){
if (htab.scrollTop >= htab1.offsetHeight) {
htab.scrollTop-=htab2.offsetHeight;
}else{
htab.scrollTop+=1;
}
}
var MyMar=setInterval(Marquee,speed);
script>
    body>
html>

你可能感兴趣的:(wordpress)