i have a layout like this
<section id="container"> <header></header> <section id="main"></section> <footer></footer> </section>
At the moment my page is laid out like this:
------------------- | | 100px height | HEADER | |-----------------| | | | MAIN | 500px height | | |-----------------| | | | FOOTER | |-----------------| | | | | -------------------
I would like the footer to extend following the main content area to the bottom of the page, how can this be achieved?
------------------- | | 100px height | HEADER | |-----------------| | | | MAIN | 500px height | | |-----------------| | | | FOOTER | | | | | | FOOTER | -------------------
NOTE: I have noticed all answers so far will pin the footer to tje bottom of the page, however when dragged the footer simply moves down/the main container expands, I want the footer to expand.
Just wrap your . container and your . footer in a flex container with a min-height: 100vh, switch the direction to column so that they stack on top of each other, and justify the content with space between so that footer will move to the bottom.
To change the height of header or footer, you can drag the height bigger or smaller as you need in Page Layout view. Then dragging the top margin up or down as you need to change the height of the header. If you want to change the height of footer, dragging bottom margin to resize.
The reason your footer is only halfway down the page with position: absolute is that you haven't set a min-height on the body and html elements. Without that, the body only takes up as much space as you have content for it -- and then the footer is aligned with that bottom, not the bottom of the window.
I was searching for a solution to this exact problem, and I came across a very simple way of achieving the effect I was going for:
footer { box-shadow: 0 50vh 0 50vh #000; }
This creates a shadow which will fall off the screen if not needed, but otherwise will give 100vh (a full viewport height's worth) of coverage to the space below the footer, so the body background doesn't appear below it.
Although this is marked answered, it doesn't seem to fully answer the OPs question. I had the same challenge and here is what I found to work:
Here is the CSS:
html, body{ height: 100% } .site-container{ overflow: hidden; min-height: 100%; min-width: 960px; } .footer{ padding-bottom: 32000px; margin-bottom: -32000px; }
I found this here: https://www.joestrong.co.uk/blog/2012/01/12/css-tip-extend-your-sites-footer-to-the-bottom-of-the-page/ which contains more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With