I'm an iPhone Developer mainly, I'm a bit rubbish at CSS and I'm trying to make a webpage for my app.
I want to make my footer have the following properties:
All the other styling I can do myself, it's just positional styling that I find really difficult.
Can someone please explain to me how to do this in just CSS.
Set the padding of the footer to add whitespace between the content bottom and the window bottom. Create a container div that wraps the body content with position: relative; min-height: 100%; Add bottom padding to the main content div that is equal to the height plus padding of the footer.
Set margin on the footer Because you set the Body — the footer's parent element — to Flex, you can set the top margin on the footer element to Auto. This makes the footer push away from the content above, causing the footer to stick to the bottom of the page.
footer {
width: 640px;
margin: 0% -320px;
position: fixed;
left: 50%;
bottom: 0%;
}
Example: http://jsbin.com/imisig/3
Example with heaps of text: http://jsbin.com/imisig/4
Put the footer HTML into a <div id="footer">
. And the CSS would be something like this:
#footer {
width: 640px;
position: fixed;
bottom: 0px;
left: 50%;
margin-left: -320px;
}
Explanation
width
property sets the width to 640px
position: fixed
will make it so it scrolls with the pagebottom: 0px
makes it fixed on the bottom of the page (distance to bottom = 0px)left: 50%
puts the left side of the div
to the center of the pagemargin-left: -320px
- now we have to move it 320px from the left to make it centeredIf 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