jQuery缩放效果后div移位 [英] div shifts after jquery scale effect

查看:171
本文介绍了jQuery缩放效果后div移位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个div,在缩放后,它会向左和向下移动,所以我看不到为什么发生这种情况.有关所有代码,请参见 http://jsfiddle.net/7A7gs/2 .

I have a div that after scaling, shifts to the left and down and I can't see why this is happening. See http://jsfiddle.net/7A7gs/2 for all code.

我尝试使用动画宽度/高度而不是比例,并且发生了相同的事情.我也尝试过尺寸而不是比例尺.一样.

I've tried using animate width/height instead of scale, and the same thing happens. I've also tried size instead of scale. Same thing.

此外,如果我将比例从两个"都更改为垂直,则div不会移动.如果我将标度更改为水平",则div会移动.

Also, if I change the scale from 'both' to vertical, the div does not shift. If I change the scale to 'horizontal' the div shifts.

请让我知道我在哪里出问题了! MTIA.

Please let me know where I'm going wrong here! MTIA.

所需的行为是单击的div移至窗口的左上角(当前正确运行),然后扩展以填充窗口的宽度和高度.

The desired behaviour is that the clicked div shifts to the top left corner of the window (this is currently working correctly), then expands to fill the width and height of the window.

当前,它会扩展以填充窗口的宽度和高度,然后向下和向左移动,这不是所需的行为.

Currently, it expands to fill the width and height of the window and then shifts downward and to the left, which is not the desired behaviour.

推荐答案

最后,似乎是偏移位置引起了问题.我更改了代码以在相对定位和绝对定位之间切换,并且动画停止了跳跃.

In the end, it appears that the offset positioning was causing the problem. I changed the code to switch between relative and absolute positioning and the animation stopped jumping.

这篇关于jQuery缩放效果后div移位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆