在IE6下面,不会滚动,且显示不在一行
在IE7及火狐下都没问题,显示在一行,且会滚动<div id="demo">
<div id="indemo">
<div id="demo1">
<a href="http://www.xxx.com/" title="" target="_blank">XXX网</a>
<a href="http://www.2222.com" title="" target="_blank">2222网</a>
</div>
<div id="demo2"></div>
</div>
</div>
<script>
<!--
var speed=30; //数字越大速度越慢
var tab=document.getElementById("demo");
var tab1=document.getElementById("demo1");
var tab2=document.getElementById("demo2");
tab2.innerHTML=tab1.innerHTML;
function Marquee(){
if(tab2.offsetWidth-tab.scrollLeft<=0)
tab.scrollLeft-=tab1.offsetWidth
else{
tab.scrollLeft++;
}
}
var MyMar=setInterval(Marquee,speed);
tab.onmouseover=function() {clearInterval(MyMar)};
tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};
-->
</script>以下为CSS:
/*滚动*/#demo {
overflow:hidden;
width: 940px;
height:40px;
margin:5px 80px;
}
#demo li {
border: 0px solid #F2F2F2;
float:left;
}
#demo li img{
width:110px;
height:40px;
margin-top:6px;
border:1px #CCCCCE solid;
}#indemo {
float: left;
width: 880%;
}
#demo1 {
float: left;
}
#demo2 {
float: left;
}
在IE7及火狐下都没问题,显示在一行,且会滚动<div id="demo">
<div id="indemo">
<div id="demo1">
<a href="http://www.xxx.com/" title="" target="_blank">XXX网</a>
<a href="http://www.2222.com" title="" target="_blank">2222网</a>
</div>
<div id="demo2"></div>
</div>
</div>
<script>
<!--
var speed=30; //数字越大速度越慢
var tab=document.getElementById("demo");
var tab1=document.getElementById("demo1");
var tab2=document.getElementById("demo2");
tab2.innerHTML=tab1.innerHTML;
function Marquee(){
if(tab2.offsetWidth-tab.scrollLeft<=0)
tab.scrollLeft-=tab1.offsetWidth
else{
tab.scrollLeft++;
}
}
var MyMar=setInterval(Marquee,speed);
tab.onmouseover=function() {clearInterval(MyMar)};
tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};
-->
</script>以下为CSS:
/*滚动*/#demo {
overflow:hidden;
width: 940px;
height:40px;
margin:5px 80px;
}
#demo li {
border: 0px solid #F2F2F2;
float:left;
}
#demo li img{
width:110px;
height:40px;
margin-top:6px;
border:1px #CCCCCE solid;
}#indemo {
float: left;
width: 880%;
}
#demo1 {
float: left;
}
#demo2 {
float: left;
}
#demo {
overflow:hidden;
width: 940px;
height:40px;
margin:5px 80px;
}
#demo li {
border: 0px solid #F2F2F2;
float:left;
}
#demo li img{
width:110px;
height:40px;
margin-top:6px;
border:1px #CCCCCE solid;
} #indemo {
float: left;
width: 880%;
}
#demo1 {
float: left;
}
#demo2 {
float: left;
}
</style><div id="demo">
<div id="indemo">
<div id="demo1"> <a href="http://www.xxx.com/" title="" target="_blank">XXX网 </a> <a href="http://www.2222.com" title="" target="_blank">2222网 </a>
</div>
<div id="demo2"> </div>
</div>
</div>
<script>
<!--
var speed=30; //数字越大速度越慢
var tab=document.getElementById("demo");
var tab1=document.getElementById("demo1");
var tab2=document.getElementById("demo2");
tab2.innerHTML=tab1.innerHTML;
function Marquee(){
if(tab2.offsetWidth-tab.scrollLeft <=0)
tab.scrollLeft-=tab1.offsetWidth
else{
tab.scrollLeft++;
}
}
var MyMar=setInterval(Marquee,speed);
tab.onmouseover=function() {clearInterval(MyMar)};
tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};
-->
</script>
没办法,让我帮他改,懒得改,我重写了一个。
http://www.0577hr.com/ 首页里欢迎您加盟 后面的代码就是。
CSS:
.service_up{
position:relative;
width:694px;
height:16px;
overflow:hidden;
white-space:nowrap;
}
.service_up div{
position:absolute;
}
.service_up div a{
margin-right:10px;
}
JAVASCRIPT:
function setMarquee(){ //首页最新加盟会员滚动
var Tim,Div=D$("Marquee").getElementsByTagName("div")[0],A=Div.getElementsByTagName("a");
var Child=function(){
return Div.getElementsByTagName("a")[0];
}
var Left=function(s){
if(s){
Div.style.left=s+"px";
}else{
var s=Div.style.left,r=/^(.+)px$/;
if(r.test(s)){
return parseInt(s.replace(r,"$1"));
}else{
return 0
}
}
}
var Distance=function(){
return -(Child().offsetWidth+10);
}
var Play=function(){
if(Tim)clearTimeout(Tim);
var l=Left();
if(Distance()<l){
Left(l-1);
Tim=setTimeout(Play,25); //滚动速度
}else{
var o=Child();
Div.removeChild(o);
Div.appendChild(o);
Div.style.left=0;
Tim=setTimeout(Play,1000); //滚动间隔
}
}
Tim=setTimeout(Play,2000); //第一次滚动
for(var i=0;i<A.length;i++){
A[i].onmouseover=function(){
if(Tim)clearTimeout(Tim);
}
A[i].onmouseout=function(){
Tim=setTimeout(Play,500); //鼠标离开后滚动间隔
}
}
}
<div id="indemo">
<div id="demo1"> <a href="http://www.xxx.com/" title="" target="_blank">XXX网 </a> <a href="http://www.2222.com" title="" target="_blank">2222网 </a>
</div>
<div id="demo2"> </div>
</div>
</div>
<script>
<!--
var speed=30; //数字越大速度越慢
var tab=document.getElementById("demo");
var tab1=document.getElementById("demo1");
var tab2=document.getElementById("demo2");
tab2.innerHTML=tab1.innerHTML;
function Marquee(){
if(tab2.offsetWidth-tab.scrollLeft <=0)
tab.scrollLeft-=tab1.offsetWidth
else{
tab.scrollLeft++;
}
}
var MyMar=setInterval(Marquee,speed);
tab.onmouseover=function() {clearInterval(MyMar)};
tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};
-->
</script> <style>#demo {
overflow:hidden;
width: 940px;
height:40px;
margin:5px 80px;
}
#demo li {
border: 0px solid #F2F2F2;
float:left;
}
#demo li img{
width:110px;
height:40px;
margin-top:6px;
border:1px #CCCCCE solid;
} #indemo {
float: left;
width: 880%;
}
#demo1 {
float: left;
}
#demo2 {
float: left;
}
</style>
不是
找到原因了!
是CSS注释的问题
我在前面加了这个注释就不行,
/*滚动*/改成
/* 滚动 */
或
/*滚 动*/
就OK了