0

我需要一个扩展 div,它在初始化时仅显示 300x960 图像的顶部 30x960 以及左上角的“扩展”按钮。单击展开按钮将向下“滑动”div 以显示 300x960 的完整图像。点击其他任何地方,无论是扩展的还是收缩的,都会将用户带到广告商网站。我可以从中构建任何快速的片段吗?

4

1 回答 1

0

Try something like this:

<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>
于 2010-09-27T16:26:43.633 回答