关于这个图片滚动,我遇到了问题了

yozoh_ 2011-07-04 09:38:32

<!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=gb2312" />
<title>无标题文档</title>
</head>
<body>
<style>
.scroll_div {width:600px; height:80px;margin:0 auto; overflow: hidden; white-space: nowrap; background:#ffffff;}
.scroll_div img {width:120px;height:60px;border: 0;margin: auto 8px; border:1px #efefef solid;}
#scroll_begin, #scroll_end, #scroll_begin ul, #scroll_end ul, #scroll_begin ul li, #scroll_end ul li{display:inline;}/*设置ul和li横排*/
</style>
<script language="javascript">
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>
<h2 align="center">向左滚动</h2>
<div style="text-align:center">
<div class="sqBorder">
<!--#####滚动区域#####-->
<div id="scroll_div" class="scroll_div">
<div id="scroll_begin">


<ul onMouseOver="this.stop();" onMouseOut="this.start();">
<li><img src="bg.png"/></li>
<li><img src="bg.png" /></li>

</ul>

</div>
<div id="scroll_end"></div>
</div>
<!--#####滚动区域#####-->
</div>
<script type="text/javascript">ScrollImgLeft();</script>
</div>
<!--//向左滚动代码结束-->
</body></html>
</body>
</html>


这是我网上搜的代码,我现在想在图片的下方添加文字,即<li><img src="bg.png"/><br>哈哈</li>,他就会停止滚动,,希望大家帮我看下~或求其他能代替这个的代码。(之前想过用marquee弄滚动,又不能实现无缝循环T T)
...全文
77 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
挨踢直男 2011-07-04
  • 打赏
  • 举报
回复
<!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>
</head>
<body>
<style>
.scroll_div {width:600px; height:80px;margin:0 auto; overflow: hidden; white-space: nowrap; background:#ffffff;}
.scroll_div img {width:120px;height:60px;border: 0;margin: auto 8px; border:1px #efefef solid;}

</style>
<script language="javascript">
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>
<h2 align="center">向左滚动</h2>
<div style="text-align:center">
<div class="sqBorder">
<!--#####滚动区域#####-->

<div id="scroll_div" class="scroll_div">
<table>
<tr>
<td id="scroll_begin">
<table onMouseOver="this.stop();" onMouseOut="this.start();">
<tr>
<td><img src="http://csdnimg.cn/www/images/csdnindex_logo.gif"/><br/>哈哈</td>
<td><img src="http://csdnimg.cn/www/images/csdnindex_logo.gif"/><br/>哈哈</td>
<td><img src="http://csdnimg.cn/www/images/csdnindex_logo.gif"/><br/>哈哈</td>
<td><img src="http://csdnimg.cn/www/images/csdnindex_logo.gif"/><br/>哈哈</td>
<td><img src="http://csdnimg.cn/www/images/csdnindex_logo.gif"/><br/>哈哈</td>
<td><img src="http://csdnimg.cn/www/images/csdnindex_logo.gif"/><br/>哈哈</td>
<td><img src="http://csdnimg.cn/www/images/csdnindex_logo.gif"/><br/>哈哈</td>
<td><img src="http://csdnimg.cn/www/images/csdnindex_logo.gif"/><br/>哈哈</td>
<td><img src="http://csdnimg.cn/www/images/csdnindex_logo.gif"/><br/>哈哈</td>
<td><img src="http://csdnimg.cn/www/images/csdnindex_logo.gif"/><br/>哈哈</td>
<td><img src="http://csdnimg.cn/www/images/csdnindex_logo.gif"/><br/>哈哈</td>
<td><img src="http://csdnimg.cn/www/images/csdnindex_logo.gif"/><br/>哈哈</td>
</tr>
</table>
</td>

<td id="scroll_end"></td>
</tr>
</table>
</div>
<!--#####滚动区域#####-->
</div>
<script type="text/javascript">ScrollImgLeft();</script>
</div>
<!--//向左滚动代码结束-->
</body></html>
</body>
</html>

你的js一点问题都没有,
只不过你的布局出了点问题
table在这里使用很方便,省去很多问题

87,990

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧