Html 如何使一个 DIV 浮动在另一个 DIV 之上,而无需向下推下 CSS
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4800035/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 06:21:32 来源:igfitidea点击:
How to make a DIV float on top of another DIV without pushing down the CSS Underneath
提问by AnApprentice
Please take a look at the following example:
请看下面的例子:
I want the "overlayedFrameFooter" div to be onTOP of the frame, in a way where it doesn't add any height to the surrounding items.
我希望“overlayedFrameFooter” div 位于框架的顶部,它不会为周围的项目添加任何高度。
Any ideas?
有任何想法吗?
回答by thirtydot
- I added
position:relative
to#frame
. - I added
width:100%; text-align:center
to#overlayedFrameFooter
. - I changed
position:relative
toposition:absolute
on#overlayedFrameFooter
.
- 我添加
position:relative
到#frame
. - 我添加
width:100%; text-align:center
到#overlayedFrameFooter
. - 我换
position:relative
到position:absolute
的#overlayedFrameFooter
。
See herefor an explanation of why this works.
请参阅此处以了解其工作原理。