简体   繁体   English

100%高度div

[英]100% height div

I have a #main div that I'd like to fill the page between the header and footer when there is no content. 我有一个#main div,当没有内容时,我想在页眉和页脚之间填充页面。 When there is content, it should push the sticky footer down, which it does. 存在内容时,应将粘性页脚向下推,确实如此。

CSS: CSS:

#main {
 background: transparent url("images/main-content.png") top right repeat-y;
 clear: both;
 overflow: hidden;
 margin-top: -10px;
 height: 100%;
 min-height: 100%;
}

I'm not sure why this isn't working. 我不确定为什么这行不通。 #main inherits from #wrapper and body , so I'd think setting up 100% height and min-height of 100% would work. #main继承自#wrapperbody ,所以我认为设置100%的高度和100%的最小高度会起作用。

Site: 现场:

http://www.dentistrywithsmiles.com http://www.dentistrywithsmiles.com

Thanks in advance for your help with this. 在此先感谢您的帮助。

It's that height: auto !important; 就是那个height: auto !important; somewhere near line 146 of your CSS file. CSS文件第146行附近的某处。

It's overriding the 100% height of your wrapper, which isn't letting your main div grow. 它覆盖了包装器的100%的高度,这不会让您的主div增长。 Since your footer has a constant height, I would try adding a padding to the wrapper to make the main content div not eat into the footer, which is what happens when you turn of the height: auto !important; 由于您的页脚高度恒定,因此我将尝试在包装器中添加填充,以使主要内容div不会被页脚占用,这是在您转height: auto !important;时发生的情况height: auto !important; .

Add display:inline-block to #main (or to #wrapper , depending on what you want to do). display:inline-block添加到#main (或#wrapper ,具体取决于您要执行的操作)。 Items with display:block (such as a div or p tag by default) have 100% width and height that adjusts to the content. 具有display:block (默认情况下为div或p标签)具有100%的宽度和高度,可以根据内容进行调整。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM