2010-09-27 73 views
0

我需要一个扩展div初始化,只显示300x960图像的顶部30x960以及左上角的“扩展”按钮。点击展开按钮将“滑动”div以显示300x960的完整图像。点击其他任何地方,无论是扩大还是缩小,都会将用户带到广告客户的网站。我可以从那里创建任何快速片段?需要一些帮助,建立一个扩展div

回答

0

尝试这样:

<div style="width:960px; height:30px; position:relative; overflow:hidden"> 
<a href="http://another/site/"><img src="image.jpg" alt="" /></a> 
<input type="button" value="Expand" style="position:absolute; left:10px; top:10px" onclick="expand(this)" /> 
</div> 

<script type="text/javascript"> 
function expand(btn) 
{ 
    btn.style.display='none'; 
    slide(btn.parentNode,30); 
} 

function slide(div,curHeight) 
{ 
    if(curHeight==300)return; 
    curHeight+=10; 
    div.style.height=curHeight+'px'; 
    setTimeout(function(){slide(div,curHeight);},25); 
} 
</script> 
+0

差不多!展开按钮出现在浏览器的最左角,当图像展开时它也消失。 – 86Stang 2010-09-27 21:45:22

+0

我修好了第一个。如果你不想让按钮消失,请用“btn.style.display ='none'”删除该行。但是,点击按钮后会使用那个按钮呢? – 2010-09-28 06:41:31