CSS:停止 div 推送内容
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2438811/
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
CSS: Stopping div pushing content
提问by Melt
I'm trying to implement a CSS menu and am having a problem with the menu pushing the other content/divs down when the menu expands.
我正在尝试实现一个 CSS 菜单,但在菜单展开时菜单将其他内容/div 向下推时遇到问题。
http://www.confetti.ie/index2.aspx
http://www.confetti.ie/index2.aspx
Can anyone tell me what CSS I need to stop the main body content being pushed when the menu expands?
谁能告诉我需要什么 CSS 才能在菜单展开时停止推送主体内容?
回答by Pekka
The keyword is the CSS property position: absolute
. It makes elements "float" over the other content. Absolutely positioned menu elements won't push the page content.
关键字是 CSS 属性position: absolute
。它使元素“浮动”在其他内容上。绝对定位的菜单元素不会推送页面内容。
回答by Crozin
Use position: absolute;
to throw the element (sub menu container) out of the document flow.
使用position: absolute;
扔元素(子菜单容器)从公文流转。
回答by Taymoor Q.
Use position: absolute
for the one you want to be over and position : relative
for the one don't want to move
使用position: absolute
你想在一个position : relative
对一个不想动