信息滾動

文字無縫信息滾動:javascript

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>信息滾動</title>
	<style type="text/css">
*{margin: 0px;padding: 0px;}
ul{list-style: none;}
#hh{width: 400px;height: 144px;margin-top:100px;margin-left: 400px; background-color: green;overflow: hidden;border: 2px solid red;}

	</style>
</head>
<body>
<div id="hh">
	<ul id="con1">
		<li>一、大叔過一會你就是昆明大理石密度法規和女的名稱是</li>
		<li>二、啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊</li>
		<li>三、是水水水水水水水水水水水水水水水水</li>
		<li>四、人人人人人人人人人人人人人人人人人人人人人人人</li>
		<li>五、想嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻</li>
		<li>六、鵝鵝鵝餓鵝鵝鵝餓鵝鵝鵝餓鵝鵝鵝餓</li>
		<li>七、每天每天每天每天每天每天每天每天每天每天天</li>
		<li>八、啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦了</li>
		<li>九、想嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻</li>
		<li>十、鵝鵝鵝餓鵝鵝鵝餓鵝鵝鵝餓鵝鵝鵝餓</li>
		<li>十一、每天每天每天每天每天每天每天每天每天每天天</li>
		<li>十二、啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦了</li>
	</ul>
	<ul id="con2"></ul>
</div>	
<script type="text/javascript">
var hh=document.getElementById('hh');
var con1=document.getElementById('con1');
var con2=document.getElementById('con2');
var time=50;

hh.scrollTop=0;
con2.innerHTML=con1.innerHTML;

function scrollUp(){

	if (hh.scrollTop>=con1.offsetHeight) {
		hh.scrollTop=0;
	}else{
		hh.scrollTop++;
	}
}


var myScroll=setInterval('scrollUp()',time);

hh.onmouseover=function(){
	clearInterval(myScroll);
}
hh.onmouseout=function(){
	 myScroll=setInterval('scrollUp()',time);
}

	</script>
</body>
</html>

  

間歇性信息滾動:css

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>間歇性信息滾動</title>
	<style type="text/css">
*{margin: 0px;padding: 0px;}
ul{list-style: none;}
#hh{width: 400px;height: 144px;margin-top:100px;margin-left: 400px; background-color: green;overflow: hidden;border: 2px solid red;}

	</style>
</head>
<body>
<div id="hh">
	<ul id="con1">
		<li>一、大叔過一會你就是昆明大理石密度法規和女的名稱是</li>
		<li>二、啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊</li>
		<li>三、是水水水水水水水水水水水水水水水水</li>
		<li>四、人人人人人人人人人人人人人人人人人人人人人人人</li>
		<li>五、想嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻</li>
		<li>六、鵝鵝鵝餓鵝鵝鵝餓鵝鵝鵝餓鵝鵝鵝餓</li>
		<li>七、每天每天每天每天每天每天每天每天每天每天天</li>
		<li>八、啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦了</li>
		<li>九、想嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻</li>
		<li>十、鵝鵝鵝餓鵝鵝鵝餓鵝鵝鵝餓鵝鵝鵝餓</li>
		<li>十一、每天每天每天每天每天每天每天每天每天每天天</li>
		<li>十二、啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦了</li>
	</ul>
	<ul id="con2"></ul>
</div>	
<script type="text/javascript">
var hh=document.getElementById('hh');
var con1=document.getElementById('con1');
var con2=document.getElementById('con2');
var time=50;
var liheight=24;
hh.scrollTop=0;
con2.innerHTML=con1.innerHTML;

function starMove(){
	hh.scrollTop++;
	 myScroll=setInterval('scrollUp()',time);
}

function scrollUp(){
   // hh.scrollTop++;
   if(hh.scrollTop%liheight==0){
   	clearInterval(myScroll);
   	setTimeout('starMove()',2000);
   }else{
   	hh.scrollTop++;
   	if (hh.scrollTop>=hh.scrollHeight/2) {
   		hh.scrollTop=0;
   	}
   }
}

 setTimeout('starMove()',2000);

	</script>
</body>
</html>
相關文章
相關標籤/搜索