可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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! =)
回答1:
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.
回答2:
You need to set postion:relative of outer DIV and position:absolute of inner div.
Try this. Here is the Demo
回答3:
You want to use position: absolute
while inside the other div.
DEMO
回答4:
you can use position:relative;
inside #one div and position:absolute
inside #two div. you can see it