Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Content with 100% between header and footer

Tags:

html

css

flexbox

Lets assume I have the following layout (see image below)... I have a header (A) at the top, footer (C) that is always at the bottom and container (B) that is in the middle and should fill the space left between the header and the footer by 100%.

enter image description here

Can't think of any way how to achieve this using pure css. Any ideas would be appreciated!

like image 352
King Julien Avatar asked Jul 06 '12 21:07

King Julien


People also ask

What comes between header and footer in HTML?

The center div will always take up 100% of the space between the two, and it'll grow based on it's inner content.

How do I add space between header and footer in HTML?

There's a number of ways: Add a bottom margin-bottom or padding-bottom to the first header. Add a margin-top or padding-top to the second header. Add a <br> after the first header, inside the header tags.

Why is footer so high HTML?

If the footer is too large, then it takes up too much space at the bottom of the Web page. Within the "#footer" bracket tags of "{" and "}" are listed the "width: Xpx;" and "height: Xpx;" coding. Change the width to "100%" to make the footer as wide as the rest of the website content.


1 Answers

Your question pretty much describes how standard block-level elements, such as DIVs, behave. The center div will always take up 100% of the space between the two, and it'll grow based on it's inner content.

That said, I'm going to assume you want a FIXED footer - one that stays positioned at the bottom of the browser window. This is achiavable using a number of techniques, one of which is using absolutly positioning:

<div id="header">Header</div> 
<div id="content">Main Content</div> 
<div id="footer">Footer</div> 

Style:

#header, #footer, #content { position: absolute; left: 0; width: 100%; }
#header, #footer { overflow: hidden; background: #444; height: 100px; }
#header { top: 0; }
#content { top: 100px; bottom: 100px; overflow: auto; background: #CCC; }
#footer { bottom: 0; }​

http://jsfiddle.net/U9wfy/

like image 109
Derek Hunziker Avatar answered Oct 12 '22 07:10

Derek Hunziker