码迷,mamicode.com
首页 > Web开发 > 详细

js实现文字无间断左右滚动和图片左右滚动

时间:2017-11-09 15:07:42      阅读:197      评论:0      收藏:0      [点我收藏+]

标签:nowrap   img   padding   add   set   文字   ref   height   sse   

var MyMar=setInterval(Marquee,speed);
scroll_div.onmouseover=function() {clearInterval(MyMar);}
scroll_div.onmouseout=function() {MyMar=setInterval(Marquee,speed);}
}
</script>
<div id="gongao">
<div style="width:900px;height:30px;margin:0 auto;white-space: nowrap;overflow:hidden;" id="scroll_div" class="scroll_div">
<div id="scroll_begin">
${affiche.content} ${affiche.content} ${affiche.content}
${affiche.content} ${affiche.content} ${affiche.content}
</div>
<div id="scroll_end"></div>
</div>
<script type="text/javascript">ScrollImgLeft();</script>
</div>

//实现图片左右滚动

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>XuLinJie_</title>
<!--<link href="js图片滚动.css" type="text/css" rel="stylesheet">
<script src="js图片滚动.js"></script>-->
</head>
<style>
*{
margin: 0px 0px;
padding:0px 0px;
}
.scroll_div {
width:100%;
height:400px;
margin:0 0;
overflow: hidden;
white-space: nowrap;
background:#ffffff;
}
.scroll_div img {
width:100%;
height:400px;
}
#scroll_begin, #scroll_end, #scroll_begin ul, #scroll_end ul, #scroll_begin ul li, #scroll_end ul li{
display:inline;
}/*设置ul和li横排*/
</style>
<body>
<div id="scroll_div" class="scroll_div">
<div id="scroll_begin">
<ul>
<li><a href="#"><img src="../assets/i/banner.png"></a></li>
<li><a href="#"><img src="../assets/i/picture.png"></a></li>
<li><a href="#"><img src="../assets/i/banner.png"></a></li>
<li><a href="#"><img src="../assets/i/picture.png"></a></li>
<li><a href="#"><img src="../assets/i/banner.png"></a></li>
<li><a href="#"><img src="../assets/i/picture.png"></a></li>
<li><a href="#"><img src="../assets/i/banner.png"></a></li>
<li><a href="#"><img src="../assets/i/picture.png"></a></li>
</ul>
</div>
<div id="scroll_end"></div>
</div>
<!--#####滚动区域#####-->

<script type="text/javascript">
ScrollImgLeft();
function ScrollImgLeft(){
var speed=10;
var scroll_begin = document.getElementById("scroll_begin");
var scroll_end = document.getElementById("scroll_end");
var scroll_div = document.getElementById("scroll_div");
scroll_end.innerHTML=scroll_begin.innerHTML;
function Marquee(){
if(scroll_end.offsetWidth-scroll_div.scrollLeft<=0)
{
scroll_div.scrollLeft-=scroll_begin.offsetWidth;
}
else
{
scroll_div.scrollLeft++;
}
}
var MyMar=setInterval(Marquee,speed);
scroll_div.onmouseover=function()
{
clearInterval(MyMar);
}
scroll_div.onmouseout=function()
{
MyMar=setInterval(Marquee,speed);
}
}
</script>
</body>
</html>

 

js实现文字无间断左右滚动和图片左右滚动

标签:nowrap   img   padding   add   set   文字   ref   height   sse   

原文地址:http://www.cnblogs.com/ouchen0312/p/7808606.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!