相对于另一个DIV的位置DIV? [英] Position DIV relative to another DIV?
问题描述
是否可以相对于另一个DIV定位DIV?我想这可以通过首先将它放在参考DIV,然后使用 position:relative
。但是,我不知道如何做,而不影响参考DIV的内容。如何正确地完成此操作?
请参阅: http://jsfiddle.net/CDmGQ
谢谢! =)
将父DIV的位置
c $ c> relative (指定偏移量,即 left
, top
没有必要),然后将 position:absolute
应用到您想要的偏移量的子DIV。
这很简单,应该做的很好。 p>
Is it possible to position a DIV relative to another DIV? I imagine this can be done by first placing it inside of the reference DIV, and then using position: relative
. However, I can't figure out how to do this without affecting the contents of the reference DIV. How can I do this properly?
See: http://jsfiddle.net/CDmGQ
Thanks! =)
First set position
of the parent DIV to relative
(specifying the offset, i.e. left
, top
etc. is not necessary) and then apply position: absolute
to the child DIV with the offset you want.
It's simple and should do the trick well.
这篇关于相对于另一个DIV的位置DIV?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!