网页制作如何让图片从左到右循环移动
展开全部
网页制作(HTML)让图片从左到右循环移动使用 css +js完成。
例如:从左向右循环移动
<html>
<head><title>图片向右循环滚动</title><head>
<body>
<div id=demo style="overflow:hidden;height:68px;width:800px;"><table align=left cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top nowrap="nowrap">
<img src="http://www.newxing.com/skins/NewXing/logo.gif">
<img src="http://www.newxing.com/skins/NewXing/logo.gif">
<img src="http://www.newxing.com/skins/NewXing/logo.gif">
<img src="http://www.newxing.com/skins/NewXing/logo.gif">
</td><td id=demo2 valign=top></td></tr></table></div>
<script>
var speed = 30;
demo2.innerHTML = demo1.innerHTML;
function Marquee() {
if(demo.scrollLeft<=0)
demo.scrollLeft+=demo2.offsetWidth
else {
demo.scrollLeft--;
}
};
var MyMar = setInterval(Marquee, speed);
demo.onmouseover = function() {
clearInterval(MyMar)
};
demo.onmouseout = function() {
MyMar = setInterval(Marquee, speed)
};
</SCRIPT>
</body>
</html>
例如:从左向右循环移动
<html>
<head><title>图片向右循环滚动</title><head>
<body>
<div id=demo style="overflow:hidden;height:68px;width:800px;"><table align=left cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top nowrap="nowrap">
<img src="http://www.newxing.com/skins/NewXing/logo.gif">
<img src="http://www.newxing.com/skins/NewXing/logo.gif">
<img src="http://www.newxing.com/skins/NewXing/logo.gif">
<img src="http://www.newxing.com/skins/NewXing/logo.gif">
</td><td id=demo2 valign=top></td></tr></table></div>
<script>
var speed = 30;
demo2.innerHTML = demo1.innerHTML;
function Marquee() {
if(demo.scrollLeft<=0)
demo.scrollLeft+=demo2.offsetWidth
else {
demo.scrollLeft--;
}
};
var MyMar = setInterval(Marquee, speed);
demo.onmouseover = function() {
clearInterval(MyMar)
};
demo.onmouseout = function() {
MyMar = setInterval(Marquee, speed)
};
</SCRIPT>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>水平无接缝滚动代码_</title>
<style type="text/css">
<!--
TD {FONT-SIZE: 12px;}
</style>
</head>
<body>
<div id=demo style="OVERFLOW: hidden; WIDTH: 760px; align: center">
<table cellspacing="0" cellpadding="0" align="center"
border="0">
<tbody>
<tr>
<td id="marquePic1" valign="top">
<table width="958" height="130" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="95" height="110" align="center">1</td>
<td width="95" align="center">2</td>
<td width="95" align="center">3</td>
<td width="95" align="center">4</td>
<td width="95" align="center">5</td>
<td width="95" align="center">6</td>
<td width="95" align="center">7</td>
<td width="95" align="center">8</td>
</tr>
<tr>
<td height="20" align="center" bgcolor="#0099FF">0</td>
<td align="center">a</td>
<td align="center">b</td>
<td align="center">c</td>
<td align="center">d</td>
<td align="center">e</td>
<td align="center">f</td>
<td align="center" bgcolor="#FF6633">g</td>
</tr>
</table>
</td>
<td id="marquePic2" valign="top"></td>
</tr>
</tbody>
</table>
</div>
<p>
<script type=text/javascript>
var speed=30
marquePic2.innerHTML=marquePic1.innerHTML
demo.scrollLeft=demo.scrollWidth
function Marquee(){
if(demo.scrollLeft<=0)
demo.scrollLeft+=demo2.offsetWidth
else{
demo.scrollLeft--
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
</p>
</body>
</html>
你可以把<td></td>之间的0-9或a、b……g换成你想放的图片或文字
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>水平无接缝滚动代码_</title>
<style type="text/css">
<!--
TD {FONT-SIZE: 12px;}
</style>
</head>
<body>
<div id=demo style="OVERFLOW: hidden; WIDTH: 760px; align: center">
<table cellspacing="0" cellpadding="0" align="center"
border="0">
<tbody>
<tr>
<td id="marquePic1" valign="top">
<table width="958" height="130" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="95" height="110" align="center">1</td>
<td width="95" align="center">2</td>
<td width="95" align="center">3</td>
<td width="95" align="center">4</td>
<td width="95" align="center">5</td>
<td width="95" align="center">6</td>
<td width="95" align="center">7</td>
<td width="95" align="center">8</td>
</tr>
<tr>
<td height="20" align="center" bgcolor="#0099FF">0</td>
<td align="center">a</td>
<td align="center">b</td>
<td align="center">c</td>
<td align="center">d</td>
<td align="center">e</td>
<td align="center">f</td>
<td align="center" bgcolor="#FF6633">g</td>
</tr>
</table>
</td>
<td id="marquePic2" valign="top"></td>
</tr>
</tbody>
</table>
</div>
<p>
<script type=text/javascript>
var speed=30
marquePic2.innerHTML=marquePic1.innerHTML
demo.scrollLeft=demo.scrollWidth
function Marquee(){
if(demo.scrollLeft<=0)
demo.scrollLeft+=demo2.offsetWidth
else{
demo.scrollLeft--
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
</p>
</body>
</html>
你可以把<td></td>之间的0-9或a、b……g换成你想放的图片或文字
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询