我有一些代码应该可以使图像变小,直到它从屏幕上消失。如果我将图像放在 div
中,它将无法正常工作。如果我将它从 div
中取出,它会正常工作。
但是我需要它在 div
中工作。我该如何解决这个问题?
如果 img
不在 div
中,代码可以正常工作,但当它在 div
中时,代码就会出错。
setTimeout(function(){
$("#thrid").show('fast').animate({
top : '-=-300',
width: 0,
height: 0
},
{duration: 1000});
},2000);
CSS:
#thrid{
display:none;
position:absolute;
left: 592px;
top: 160px;
}
HTML:
<div id="thrid">
<img src="images/thrid.png" alt="thrid">
</div>
这就是它对 div
所做的事情:
http://jsfiddle.net/xMV5Q/3/
这就是我想要它做的事情: http://jsfiddle.net/xMV5Q/1/
最佳答案
尝试将 img 的宽度和高度设置为 100%:
#city2 img {
height: 100%;
width: 100%;
}
关于javascript - jQuery 缩放功能不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13636982/