两个非常不错的产品图片无缝滚动JS+CSS代码, 有时候我们一个网页模板文件里放置2个以上的JS就会产生冲突,可以尝试更换一个:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>左右无间断滚动</title>
<style type=”text/css” media=”all”>
.d1 {
margin:10px auto;
width:200px;
border:#103E63 1px solid;
background-color:#EFEFEF;
height:auto;
overflow:hidden;
white-space:nowrap;
}
.d2 {
margin:0px auto;
background-color:#FF9933;
}
.div2 {
width:auto;
height:auto;
font-size:12px;
float:left;
overflow:hidden;
}
ul{
margin:0px;
padding:9px;
list-style:none;
line-height:19px;
font-size:12px;
}
a:link,a:visited{
color:#3F78CF;
text-decoration:none;
}
a:hover{
color:#FF00CC;
text-decoration:underline;
}
</style>
<script language=”javascript” type=”text/javascript”>
var s,s2,s3,s4,timer;
function init(){
s=getid(“div1”);
s2=getid(“div2”);
s3=getid(“div3”);
s4=getid(“scroll”);
s4.style.width=(s2.offsetWidth*2+100)+”px”;
s3.innerHTML=s2.innerHTML;
timer=setInterval(mar,30)
}
function mar(){
if(s2.offsetWidth<=s.scrollLeft){
s.scrollLeft-=s2.offsetWidth;
}else{s.scrollLeft++;}
}
function getid(id){
return document.getElementById(id);
}
window.onload=init;
</script>
</head>
<body>
<div class=”d1″ id=”div1″ onmouseover=”clearInterval(timer)” onmouseout=”timer=setInterval(mar,30)”>
<div class=”scroll” id=”scroll”>
<div class=”div2″ id=”div2″>
<ul>
<li><a href=”/Item/80.aspx” target=”_self”>考察合川网络信息建设情况</a></li>
<li><a href=”/Item/79.aspx” target=”_self”>政协委员视察大石镇农业特色产业</a></li>
<li><a href=”/Item/78.aspx” target=”_self”>对接好融资渠道 加快推进项目建设</a></li>
<li><a href=”/Item/77.aspx” target=”_self”>重庆市油菜高产创建现场培训会在合召开</a></li>
<li><a href=”/Item/76.aspx” target=”_self”>合川区人大常委会举行纪念改革开放30周年…</a></li>
</ul>
</div>
<div id=”div3″ class=”div2″></div>
</div>
</div>
</body>
</html>
第二个:
<style type=”text/css”>
<!–
#demo {
background: #FFF;
overflow:hidden;
border: 1px dashed #CCC;
width: 500px;
}
#demo img {
border: 3px solid #F2F2F2;
}
#indemo {
float: left;
width: 800%;
}
#demo1 {
float: left;
}
#demo2 {
float: left;
}
–>
</style>
向左滚动
<div id=”demo”>
<div id=”indemo”>
<div id=”demo1″>
<a href=”#”><img src=”http://www.cnrui.cn/other/link/Clear_logo.gif” border=”0″ /></a>
<a href=”#”><img src=”http://www.cnrui.cn/other/link/Clear_logo.gif” border=”0″ /></a>
<a href=”#”><img src=”http://www.cnrui.cn/other/link/Clear_logo.gif” border=”0″ /></a>
<a href=”#”><img src=”http://www.cnrui.cn/other/link/Clear_logo.gif” border=”0″ /></a>
<a href=”#”><img src=”http://www.cnrui.cn/other/link/Clear_logo.gif” border=”0″ /></a>
<a href=”#”><img src=”http://www.cnrui.cn/other/link/Clear_logo.gif” border=”0″ /></a>
</div>
<div id=”demo2″></div>
</div>
</div>
<script>
<!–
var speed=10; //数字越大速度越慢
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>