javascript - jQuery 缩放功能不起作用

标签 javascript jquery

我有一些代码应该可以使图像变小,直到它从屏幕上消失。如果我将图像放在 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/

相关文章:

javascript - 为什么我的 jquery 验证器没有显示任何警报消息?

javascript - Ti.App.fireEvent 不起作用;错误未捕获类型错误 : Cannot read property 'App' of undefined

javascript - jQuery的slideDown()和slideUp()的替代方案不影响显示属性

javascript - 如何在 v-carousel 中获取当前项目索引?

javascript - 不同医生类型的相对维度

jquery - 如何让 jQuery 在图像褪色之前添加占位符?

javascript - 如何避免重定向两次(react-router-redux)?

javascript - D3 : scale and color for choropleth map

JQuery,由于图像内容错误识别了 div 的高度

html - 移动应用程序上的 Reddit 外星人动画如何运作?