页面上有多个部分重叠的DIV,这些DIV都在一个大DIV里,划过内部DIV时,使该层位于最上层,这样的代码怎么
2个回答
展开全部
只要你将div层中的id名字写不一样就可以了,应该是可以见很多个的,但是在你下面js中也要相应的改成对应的div层的id名字,不然js效果就没了
比如<div id="marquees">第二个叫<div id="marquees1">在你下面的js中with(marquees)就应该在写一个with(marquees1)的,这样就好使了,你试试,我给你写出来你试试看看。
<div id="marquees">
<a href="javascript:">1.你可曾有过无数的梦想,</a><br>
<br>
<a href="javascript:">2.却在时光的流逝里幻灭 .</a><br>
<br>
<a href="javascript:">3.你可曾对未来期待憧憬,</a><br>
<br>
<a href="javascript:">4.却在成长的岁月中迷失.</a><br>
<br>
</div>
<div id="marquees1">
<a href="javascript:">1.你可曾有过无数的梦想,</a><br>
<br>
<a href="javascript:">2.却在时光的流逝里幻灭 .</a><br>
<br>
<a href="javascript:">3.你可曾对未来期待憧憬,</a><br>
<br>
<a href="javascript:">4.却在成长的岁月中迷失.</a><br>
<br>
</div>
<script language="JavaScript">
marqueesHeight=140;
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;
//scrolldelay:500
if(preTop==marquees.scrollTop){
marquees.scrollTop=templayer.offsetHeight-marqueesHeight;
marquees.scrollTop+=1;
//scrolldelay:500;
}
}
with(marquees1){
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;
}
marquees1.innerHTML=templayer.innerHTML+templayer.innerHTML;
setInterval("scrollUp()",30);
}
document.body.onload=init;
function scrollUp(){
if(stopscroll==true) return;
preTop=marquees1.scrollTop;
marquees1.scrollTop+=1;
//scrolldelay:500
if(preTop==marquees1.scrollTop){
marquees1.scrollTop=templayer.offsetHeight-marqueesHeight;
marquees1.scrollTop+=1;
//scrolldelay:500;
}
}
</script>
只要id对应上,写几个都没问题
比如<div id="marquees">第二个叫<div id="marquees1">在你下面的js中with(marquees)就应该在写一个with(marquees1)的,这样就好使了,你试试,我给你写出来你试试看看。
<div id="marquees">
<a href="javascript:">1.你可曾有过无数的梦想,</a><br>
<br>
<a href="javascript:">2.却在时光的流逝里幻灭 .</a><br>
<br>
<a href="javascript:">3.你可曾对未来期待憧憬,</a><br>
<br>
<a href="javascript:">4.却在成长的岁月中迷失.</a><br>
<br>
</div>
<div id="marquees1">
<a href="javascript:">1.你可曾有过无数的梦想,</a><br>
<br>
<a href="javascript:">2.却在时光的流逝里幻灭 .</a><br>
<br>
<a href="javascript:">3.你可曾对未来期待憧憬,</a><br>
<br>
<a href="javascript:">4.却在成长的岁月中迷失.</a><br>
<br>
</div>
<script language="JavaScript">
marqueesHeight=140;
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;
//scrolldelay:500
if(preTop==marquees.scrollTop){
marquees.scrollTop=templayer.offsetHeight-marqueesHeight;
marquees.scrollTop+=1;
//scrolldelay:500;
}
}
with(marquees1){
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;
}
marquees1.innerHTML=templayer.innerHTML+templayer.innerHTML;
setInterval("scrollUp()",30);
}
document.body.onload=init;
function scrollUp(){
if(stopscroll==true) return;
preTop=marquees1.scrollTop;
marquees1.scrollTop+=1;
//scrolldelay:500
if(preTop==marquees1.scrollTop){
marquees1.scrollTop=templayer.offsetHeight-marqueesHeight;
marquees1.scrollTop+=1;
//scrolldelay:500;
}
}
</script>
只要id对应上,写几个都没问题
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询