div+css 中循环不间断滚动代码修改(高手进)
帮我看下下面代码的修改,这是横向滚动的,如果要把它改成从下往上滚动的呢,怎么改?急,在线等!(改时可以全部拷过去,这是全页面的。)<!DOCTYPEhtmlPUBLIC"...
帮我看下下面代码的修改,这是横向滚动的,如果要把它改成从下往上滚动的呢,怎么改?
急,在线等!
(改时可以全部拷过去,这是全页面的。)
<!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>Div+Css+JS替代Marquee滚动效果(上) -- 无缝滚动</title>
<style type="text/css">
.Mar
{
background: #FFF;
overflow: hidden;
border: 1px dashed #CCC;
width: 800px; /*页面滚动需要显示的宽度*/
}
.Mar img
{
border: 3px solid #F2F2F2;
width: 124px;
height: 93px;
}
.inMar
{
float: left;
width: 3500px; /*能在一行放下所有滚动的图片的总宽度*2 像素值或者百分比*/
}
</style>
</head>
<body>
<div id="Mar" class="Mar">
<div id="inMar" class="inMar">
<div id="Mar1" style="float:left;">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>轿车:1</td>
<td>轿车:2</td>
<td>轿车:3</td>
<td>轿车:4</td>
<td>轿车:5</td>
<td>轿车:6</td>
<td>轿车:7</td>
<td>轿车:8</td>
<td>轿车:9</td>
<td>轿车:10</td>
<td>轿车:11</td>
<td>轿车:12</td>
</tr>
</table>
</div>
<div id="Mar2" style="float:left;">
</div>
</div>
</div>
<script language="javascript" type="text/javascript">
var speed = 12; //数字越小速度越快
var div = document.getElementById("Mar");
var div1 = document.getElementById("Mar1");
var div2 = document.getElementById("Mar2");
div2.innerHTML = div1.innerHTML;
function Marquee() {
//向右滚动
//if (div.scrollLeft <= 0)
//div.scrollLeft += div2.offsetWidth
//else {
//div.scrollLeft--
//}
//向左滚动
if (div2.offsetWidth - div.scrollLeft <= 0)
div.scrollLeft -= div1.offsetWidth
else {
div.scrollLeft++;
}
}
var MyMarquee = setInterval(Marquee, speed);
div.onmouseover = function() { clearInterval(MyMarquee) };
div.onmouseout = function() { MyMarquee = setInterval(Marquee, speed) };
</script>
</body>
</html> 展开
急,在线等!
(改时可以全部拷过去,这是全页面的。)
<!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>Div+Css+JS替代Marquee滚动效果(上) -- 无缝滚动</title>
<style type="text/css">
.Mar
{
background: #FFF;
overflow: hidden;
border: 1px dashed #CCC;
width: 800px; /*页面滚动需要显示的宽度*/
}
.Mar img
{
border: 3px solid #F2F2F2;
width: 124px;
height: 93px;
}
.inMar
{
float: left;
width: 3500px; /*能在一行放下所有滚动的图片的总宽度*2 像素值或者百分比*/
}
</style>
</head>
<body>
<div id="Mar" class="Mar">
<div id="inMar" class="inMar">
<div id="Mar1" style="float:left;">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>轿车:1</td>
<td>轿车:2</td>
<td>轿车:3</td>
<td>轿车:4</td>
<td>轿车:5</td>
<td>轿车:6</td>
<td>轿车:7</td>
<td>轿车:8</td>
<td>轿车:9</td>
<td>轿车:10</td>
<td>轿车:11</td>
<td>轿车:12</td>
</tr>
</table>
</div>
<div id="Mar2" style="float:left;">
</div>
</div>
</div>
<script language="javascript" type="text/javascript">
var speed = 12; //数字越小速度越快
var div = document.getElementById("Mar");
var div1 = document.getElementById("Mar1");
var div2 = document.getElementById("Mar2");
div2.innerHTML = div1.innerHTML;
function Marquee() {
//向右滚动
//if (div.scrollLeft <= 0)
//div.scrollLeft += div2.offsetWidth
//else {
//div.scrollLeft--
//}
//向左滚动
if (div2.offsetWidth - div.scrollLeft <= 0)
div.scrollLeft -= div1.offsetWidth
else {
div.scrollLeft++;
}
}
var MyMarquee = setInterval(Marquee, speed);
div.onmouseover = function() { clearInterval(MyMarquee) };
div.onmouseout = function() { MyMarquee = setInterval(Marquee, speed) };
</script>
</body>
</html> 展开
2个回答
展开全部
<div id=demo style=overflow:hidden;height:139;width:232;background:#f4f4f4;color:#ffffff><div id=demo1><img src="http://www.lanrentuku.com/down/js/images/12460764740.jpg"><img src="http://www.lanrentuku.com/down/js/images/12460764741.jpg"><img src="http://www.lanrentuku.com/down/js/images/12460764742.jpg"><img src="http://www.lanrentuku.com/down/js/images/12460764743.jpg"><img src="http://www.lanrentuku.com/down/js/images/12460764744.jpg"></div>
<div id=demo2></div>
</div>
<script>
var speed=50
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetTop-demo.scrollTop<=0)
demo.scrollTop-=demo1.offsetHeight
else{
demo.scrollTop++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
换成TOP,width换成height就可以了
衢州网站建设 http://www.daquzhou.net
<div id=demo2></div>
</div>
<script>
var speed=50
demo2.innerHTML=demo1.innerHTML
function Marquee(){
if(demo2.offsetTop-demo.scrollTop<=0)
demo.scrollTop-=demo1.offsetHeight
else{
demo.scrollTop++
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
换成TOP,width换成height就可以了
衢州网站建设 http://www.daquzhou.net
参考资料: 衢州网站建设 http://www.daquzhou.net
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询