怎样让文字或图片在网页中无缝滚动?
1个回答
展开全部
文字向上无缝滚动
<div id=marquees style="height=100px;LEFT: 60px; POSITION: absolute; TOP: 100px;"><font style="font-family:宋体; color:white; font-size:14px;line-height=15px">
<a href="#">你在做什么</a><br>
<br>
<a href="#">我在仰望天空</a><br>
<br>
<a href="#">30度仰望是什么</a><br>
<br>
<a href="#">是我想念她的角度</a><br>
<br>
<a href="#">为什么要把头抬到30度</a><br>
<br>
<a href="#">为了不让我的眼泪掉下来</a><br>
<br>
<br>
<br>
</div>
<script language="JavaScript">
marqueesHeight=100;
stopscroll=false;
with(marquees){
style.width=0;
style.height=marqueesHeight;
style.overflowX="visible";
style.overflowY="hidden";
noWrap=true;
onmouseover=new Function("stopscroll=true");
onmouseout=new Function("stopscroll=false");
}
document.write('<div id="templayer" style="position:absolute;z-index:1;visibility:hidden"></div>');
preTop=0; currentTop=0;
function init(){
templayer.innerHTML="";
while(templayer.offsetHeight<marqueesHeight){
templayer.innerHTML+=marquees.innerHTML;
}
marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;
setInterval("scrollup()",30);
}
document.body.onload=init;
function scrollup(){
if(stopscroll==true) return;
preTop=marquees.scrollTop;
marquees.scrollTop+=1;
if(preTop==marquees.scrollTop){
marquees.scrollTop=templayer.offsetHeight-marqueesHeight;
marquees.scrollTop+=1;
}
}
</script>
<div id=marquees style="height=100px;LEFT: 60px; POSITION: absolute; TOP: 100px;"><font style="font-family:宋体; color:white; font-size:14px;line-height=15px">
<a href="#">你在做什么</a><br>
<br>
<a href="#">我在仰望天空</a><br>
<br>
<a href="#">30度仰望是什么</a><br>
<br>
<a href="#">是我想念她的角度</a><br>
<br>
<a href="#">为什么要把头抬到30度</a><br>
<br>
<a href="#">为了不让我的眼泪掉下来</a><br>
<br>
<br>
<br>
</div>
<script language="JavaScript">
marqueesHeight=100;
stopscroll=false;
with(marquees){
style.width=0;
style.height=marqueesHeight;
style.overflowX="visible";
style.overflowY="hidden";
noWrap=true;
onmouseover=new Function("stopscroll=true");
onmouseout=new Function("stopscroll=false");
}
document.write('<div id="templayer" style="position:absolute;z-index:1;visibility:hidden"></div>');
preTop=0; currentTop=0;
function init(){
templayer.innerHTML="";
while(templayer.offsetHeight<marqueesHeight){
templayer.innerHTML+=marquees.innerHTML;
}
marquees.innerHTML=templayer.innerHTML+templayer.innerHTML;
setInterval("scrollup()",30);
}
document.body.onload=init;
function scrollup(){
if(stopscroll==true) return;
preTop=marquees.scrollTop;
marquees.scrollTop+=1;
if(preTop==marquees.scrollTop){
marquees.scrollTop=templayer.offsetHeight-marqueesHeight;
marquees.scrollTop+=1;
}
}
</script>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询