I've got a completely horizontal scrolling site,
TopNav (fixed position)
Nav (fixed position)
Content (sideways scrolling)
Footer (fixed position)
Everything seems to be working great but the problem I have is that if the content is big enough to scroll horizontally, it puts the footer behind the horizontal scroll-bar, so on a few pages I made the #footer { bottom:16px } or so to take into account horizontal the scroll-bar being there.
What i'm having issues with is different monitor resolutions. Obviously the content will scroll horizontally or not based on the window size. Is there any way to keep the footer at the bottom (or above the horizontal scroll bar) NO MATTER WHAT resolution or window size?
this is possible if your footer has a fixed height. Then you will have the scroll bar above your footer. The #contentWrapper has to have an negative margin in scroll bar height plus your footer height. The #content has to have the same value as top padding, so your content at the top will not be out the page.
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.
A sticky footer pattern is one where the footer of your page "sticks" to the bottom of the viewport in cases where the content is shorter than the viewport height.
If you can be sure that the content of a webpage will extend further than the height of the user's browser window, then yes, simple static positioning should suffice. However, if the page has a short amount of content on it, a statically positioned footer may not render at the bottom of the user's browser window.
After a lot of trial and error, I found this to be the best solution for an always-on-the-bottom-footer:
HTML:
<div class="footer">
<div class="footer_contents"></div>
</div>
CSS:
.footer {
height:24px; // Replace with the height your footer should be
width: 100%; // Don't change
background-image: none;
background-repeat: repeat;
background-attachment: scroll;
background-position: 0% 0%;
position: fixed;
bottom: 0pt;
left: 0pt;
}
.footer_contents {
height:24px; // Replace with the height your footer should be
width: 1000px; // Visible width of footer
margin:auto;
}
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