Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keeping footer at the bottom of window on site that scrolls horizontal

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?

like image 547
Brandon Avatar asked May 25 '11 16:05

Brandon


People also ask

How do I keep the footer at the bottom when I scroll?

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.

How do I make the footer stick to the bottom of the screen?

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.

What is a sticky footer?

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.

Why footer is not in the bottom?

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.


1 Answers

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;

}
like image 146
Gerben Van Dijk Avatar answered Sep 21 '22 01:09

Gerben Van Dijk