图片上的透本的移进移出,做好了,可是有个BUG,不能移在文本上

donger02 2012-12-08 04:20:44
<!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>
<style type="text/css">
p,a,span {margin:0;padding:0;}
ul {list-style:none;}
img {border:none;}
#content {width:980px;margin:20px auto;}
.body_l {width:680px;float:left;}
.body_r {width:300px;float:left;}
.updiv {width:680px;padding:40px;margin:0;position:relative;}
.updiv li {float:left;margin:0 10px 0 0;padding:0;position:relative;overflow:hidden;}
.updiv li a {display:block;width:196px;height:149px;position:relative;}
.updiv li span {display:block;width:100%;height:27px;background:rgba(0,0,0,0.4);color:#fff;text-align:center;position:absolute;}
</style>
<script type="text/javascript">
window.onload = function() {
oSpan1 = document.getElementById("oLi1");
oTop=parseInt(oSpan1.style.top);
}
function start() {
if(oTop>=149) {
oTimer = setInterval(moveTop,10);
}else {
oTimer = setInterval(outTop,10);
}
}

function outTop(){
oTop++;
oSpan1.style.top = oTop + "px";
if (oTop >= 149)
{
clearInterval(oTimer);
}
}
function moveTop(){
oTop--;
oSpan1.style.top = oTop + "px";
if (oTop<=122)
clearInterval(oTimer);
}
function spanFunction() {
setTimeout(start,3000);
}
</script>
</head>

<body>
<div id="content">
<div class="body_l">
<ul id="updiv" class="updiv">
<li ><a href="#" onmouseover="start()" onmouseout="start()"><img src="images/down_img.jpg" width="196" height="149"/>
<span id="oLi1" style="top:149px;">这是第一张图片</span></a>

</li>
<li id="oLi2"><p><img src="images/down_img.jpg" />
<span class="hidden_txt" style="top:100px;">这是第2张图片</span>
</p>
</li>
<li id="oLi3"><p><img src="images/down_img.jpg" />
<span class="hidden_txt">这是第3张图片</span>
</p>
</li>
</ul>
</div>
<div class="body_r">

</div>
</div>

</body>
</html>
...全文
134 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
WarOfTheKing 2012-12-08
  • 打赏
  • 举报
回复
曾经我也像你这样写js特效,后来用了jquery后觉得以前浪费了好多精力。现在我如果要某种特效,只需在jquery里找个相似的,看懂他的源码后,copy+modify,绰绰有余了,效率高多了。这应该就是“没有必要再创造轮子”的道理。

87,992

社区成员

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

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