Dreamweaver图片循环滚动代码问题-没有正常循环
按照网上代码改的,图片循环五六张图片时会往回跳四五张图片的距离(图片大小165*215)问题出在哪里,请各位大神指教!代码如下<divid="photo-list"><u...
按照网上代码改的,图片循环五六张图片时会往回跳四五张图片的距离(图片大小165*215)问题出在哪里,请各位大神指教!
代码如下
<div id="photo-list"> <ul id="scroll">
<li><a href="#"><img src="images/product1.gif" alt="" width="165px" height="215px" border="0"/></a><br />
<li><a href="#"><img src="images/product2.gif" alt="" width="165px" height="215px" border="0"/></a><br />
<li><a href="#"><img src="images/product3.gif" width="165px" height="215px" alt=""/></a><br />
<br />
<li><a href="#"><img src="images/product4.gif" width="165px" height="215px" alt=""/></a><br />
<br />
<li><a href="#"><img src="images/product5.gif" width="165px" height="215px" alt=""/></a><br />
<br />
<li><a href="#"><img src="images/about-us.jpg" width="165px" height="215px" alt=""/></a><br />
<br />
CSS图片如下:
* { padding:0; margin:0;} /*设置所有对像的内边距为0*/
body { text-align:center;} /*设置页面居中对齐*/
#photo-list {
/* 5张图片的宽度(包含宽度、padding、border、图片间的留白)
计算:5*(165+2*5+1*2+23) - 23
之所以减去23是第5张图片的右边留白 */
width:977px;
height:300px;
margin:50px auto;
overflow:hidden; /*溢出部份将被隐藏*/
border:0px dashed #ccc;
}
#photo-list ul { list-style:none;}
#photo-list li { float:left; padding-right:23px;}
#photo-list img { border:1px solid #ddd; background:#fff; padding:5px;}
JS代码用的是http://jingyan.baidu.com/article/e4511cf3122da32b845eafb3.html,抄下来的没有改动。 展开
代码如下
<div id="photo-list"> <ul id="scroll">
<li><a href="#"><img src="images/product1.gif" alt="" width="165px" height="215px" border="0"/></a><br />
<li><a href="#"><img src="images/product2.gif" alt="" width="165px" height="215px" border="0"/></a><br />
<li><a href="#"><img src="images/product3.gif" width="165px" height="215px" alt=""/></a><br />
<br />
<li><a href="#"><img src="images/product4.gif" width="165px" height="215px" alt=""/></a><br />
<br />
<li><a href="#"><img src="images/product5.gif" width="165px" height="215px" alt=""/></a><br />
<br />
<li><a href="#"><img src="images/about-us.jpg" width="165px" height="215px" alt=""/></a><br />
<br />
CSS图片如下:
* { padding:0; margin:0;} /*设置所有对像的内边距为0*/
body { text-align:center;} /*设置页面居中对齐*/
#photo-list {
/* 5张图片的宽度(包含宽度、padding、border、图片间的留白)
计算:5*(165+2*5+1*2+23) - 23
之所以减去23是第5张图片的右边留白 */
width:977px;
height:300px;
margin:50px auto;
overflow:hidden; /*溢出部份将被隐藏*/
border:0px dashed #ccc;
}
#photo-list ul { list-style:none;}
#photo-list li { float:left; padding-right:23px;}
#photo-list img { border:1px solid #ddd; background:#fff; padding:5px;}
JS代码用的是http://jingyan.baidu.com/article/e4511cf3122da32b845eafb3.html,抄下来的没有改动。 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励10(财富值+成长值)+提问者悬赏35(财富值+成长值)
1个回答
展开全部
刚好有一个模板,只需要改下图片地址
要加图片的话直接复制这个进去,要几张复制几张<td bgcolor="#FFFF00"><a href="#"><img src="pic\38dbb6fd5266d0161f746e25952bd40735fa3549.jpg" width="500" height="300"/></a></td>
<html>
<head>
<title></title></head>
<body>
<div id="gpic" style="overflow:hidden; width:600px; height:182px;">
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td id="gpic1" valign="top" align="center">
<table width="974" border="0" align='center' cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#00FFFF"><a href="#"><img src="pic\fcfaaf51f3deb48f469552d3f21f3a292df5783b.jpg" width="500" height="300"/></a></td>
<td bgcolor="#FFFF00"><a href="#"><img src="pic\38dbb6fd5266d0161f746e25952bd40735fa3549.jpg" width="500" height="300"/></a></td>
<td bgcolor="#0000FF"><a href="#"><img src="pic\8644ebf81a4c510f5a0c1f176259252dd52aa5f7.jpg" width="500" height="300"/></a></td>
</tr>
</table>
</td>
<td id="gpic2" valign="top"></td>
</tr>
</table>
</div>
<script>
var speed=30
gpic2.innerHTML=gpic1.innerHTML
function Marquee(){
if(gpic2.offsetWidth-gpic.scrollLeft<=0)
gpic.scrollLeft-=gpic1.offsetWidth
else{
gpic.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
gpic.onmouseover=function() {clearInterval(MyMar)}
gpic.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
</body>
</html>
要加图片的话直接复制这个进去,要几张复制几张<td bgcolor="#FFFF00"><a href="#"><img src="pic\38dbb6fd5266d0161f746e25952bd40735fa3549.jpg" width="500" height="300"/></a></td>
<html>
<head>
<title></title></head>
<body>
<div id="gpic" style="overflow:hidden; width:600px; height:182px;">
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td id="gpic1" valign="top" align="center">
<table width="974" border="0" align='center' cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#00FFFF"><a href="#"><img src="pic\fcfaaf51f3deb48f469552d3f21f3a292df5783b.jpg" width="500" height="300"/></a></td>
<td bgcolor="#FFFF00"><a href="#"><img src="pic\38dbb6fd5266d0161f746e25952bd40735fa3549.jpg" width="500" height="300"/></a></td>
<td bgcolor="#0000FF"><a href="#"><img src="pic\8644ebf81a4c510f5a0c1f176259252dd52aa5f7.jpg" width="500" height="300"/></a></td>
</tr>
</table>
</td>
<td id="gpic2" valign="top"></td>
</tr>
</table>
</div>
<script>
var speed=30
gpic2.innerHTML=gpic1.innerHTML
function Marquee(){
if(gpic2.offsetWidth-gpic.scrollLeft<=0)
gpic.scrollLeft-=gpic1.offsetWidth
else{
gpic.scrollLeft++
}
}
var MyMar=setInterval(Marquee,speed)
gpic.onmouseover=function() {clearInterval(MyMar)}
gpic.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
</body>
</html>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询