Site logo

Archived topic

Stick footer to bottom of short pages

9 replies · Started by Sam on September 20, 2020

Viewing posts 1–10 of 10

Hello,

Is there a built in option to "stick" the footer to the bottom of the pages? I'm not asking to use "position: fixed;" which would always keep the footer visible, rather more as described here:

https://css-tricks.com/couple-takes-sticky-footer/

On pages with not a lot of content (eg a contact page), having the footer appear above the actual bottom of the browser window looks bad.

Thanks!

Hi Sam,

You can try the "flexbox" approach provided on the link you've given.

You can try this code:

html, body {
  height: 100%;
}
body {
  display: flex;
  flex-direction: column;
}

#page {
  flex: 1 0 auto;
}

.site-footer{
flex-shrink: 0;
}

#page is GP theme's id selector for content. .site-footer is the class selector for its footer. This should work assuming no stray blocks are added between the content and the footer.

Let us know if it works for you.

Hmm not quite, that is doing something to the width of pages without sidebar widgets. It's also creating an unnecessary vertical scrollbar.

I've included the site URL in the private info section.

Thanks David, I think that will work out for me. Would be cool to see this option built in 👍

You're welcome

This an old thread but let me post a complete thing:

/* fit footer to bottom always */

/* base functionality */	
body { display: flex; flex-direction: column; align-items: stretch; height: 100vh; }
.site { flex-grow: 1;}

/* fixes */
body.admin-bar { height: calc(100vh - 35px); } /* for logged in users to not have vertical scrolls */
html { height: fit-content; } /* not supported in some browsers but cannot hurt to fit the root too */
.container.grid-container { width: 100%; } /* fix to allow for container width set in customizer to keep working */

Try add this CSS as well:

nav#secondary-navigation {
    width: 100%;
}

Hi Anthany,

Here is something you can try adding in Appearance > Customize > Additional CSS:

@media (min-width: 769px) {
    ul#menu-secondary-nav {
        display: flex;
    }

    nav#secondary-navigation {
        margin-left: unset;
        margin-right: unset;
        align-self: center;
        width: 100%;
    }

    header#masthead {
        margin-left: unset;
        margin-right: unset;
        align-self: center;
        width: 100%;
    }

    ul#menu-secondary-nav li a {
        white-space: nowrap;
    }
    ul#menu-secondary-nav {
        justify-content:flex-end;
    }
}

Kindly modify 769 in the min-width media rule to the appropriate display width. I believe yours would be 701px.

Hope this helps! Kindly let us know how it goes. :)

You’re welcome Anthany! Glad to be of assistance! Feel free to reach out anytime you’ll need assistance with anything else. Kind regards. :)

This archived topic is closed to new replies.