Relative positioning of two divs

穿精又带淫゛_ 提交于 2019-12-07 00:40:31
ggbranch

position:relative relates to the previous div.

Div .up has height 100px, so to place .down directly below .up, .down should contain top:100px. Therefore, top:200px on .down will place it 200px below .up, which is not what you want as .up only has height 100px. Solve it by changing top attribute of .down to top:100px

If you want to position it relative to wraper, use position:absolute.

Demo: http://jsfiddle.net/6wSAJ/274

you dont need to set top:xx; if you want just to stack yellow and red modify your html to be in format '<div></div>' rather than '<div />'

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!