js實現文字無間斷左右滾動和圖片左右滾動
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">
${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>
<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 {
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實現文字無間斷左右滾動和圖片左右滾動