重新计算绝对定位元素的位置? [英] Recalculating absolute positioned elements position?

查看:67
本文介绍了重新计算绝对定位元素的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些相对于文档正文绝对定位的元素.

I have some elements positioned absolutely, relative to document body.

在DOM内的某处附加了某些内容后,也应该重新定位绝对定位的元素.

When something is appended, somewhere inside DOM, then absolute positioned elements should be repositioned as well.

问题是,如何知道DOM在内部某个地方被更改了?

The question is, how to know that DOM was changed somewhere there inside?

第二个想法是听文档的高度和宽度变化,我认为这是最有效的方法.

The second idea was to listen to document height and width changes, which i think is the most efficient way to do it.

还有其他方法可以做到吗?

Are there any other ways to accomplish that?

更新 http://jsfiddle.net/9nkq9/

推荐答案

绝对定位的元素是否需要相对于身体定位?

Do the absolutely positioned elements need to be positioned relative to the body?

通过将它们包装在相对位置的容器中,就我所知,可以实现结果:

By wrapping them in a container positioned relative you can acheive the result as I understand it:

http://jsfiddle.net/9nkq9/1/

这篇关于重新计算绝对定位元素的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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