Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Footer To The Bottom #16

Open
HelloLudger opened this issue Apr 10, 2022 · 5 comments
Open

Move Footer To The Bottom #16

HelloLudger opened this issue Apr 10, 2022 · 5 comments

Comments

@HelloLudger
Copy link

On pages with little content, the footer ist not a real footer, just an element in the middle of the screen with margin-top: 10rem.

This codepen offers a solution to make it a real footer: https://codepen.io/cbracco/pen/kQmVGM (Not my code, btw. thx to the maker.)
It doesn't work as general solution, because big footers need a bigger padding-bottom for the body. But still, maybe we can find something to make the footer always a real footer?

(I am not a css expert, that's why I love this project so much ;) )

@basteyy
Copy link
Contributor

basteyy commented Apr 11, 2022

First, you are right, the linked solution is not working under every circumstance. A (more) solid solution would be a creation with flex box. The question is, do we really want to fix the footer ad the end? The specification points out, that there must be no classical "end of page footer" (https://html.spec.whatwg.org/multipage/sections.html#the-footer-element). But according to the most use cases (for example other css frameworks), the footer is sticked to the bottom.

I see three ways:

  1. We don't change it
  2. We fix the footer by default to the end of the page (but with a selector, which detect the "real" footer by body > footer)
  3. We add another class (.sticky) to the body, which pulls the footer to the end. Be using a selector on the footer element, I see no solid and responsive way to stick it.

@emareg
Copy link
Owner

emareg commented Apr 12, 2022

How about

body { display: grid; min-height: 100vh; }
body > footer { align-self: end; }

This seems to have all desired properties. However, I am not sure whether grid on the body has any negative side effects.

@basteyy
Copy link
Contributor

basteyy commented Apr 17, 2022

From my understanding, grid is for a different use case. But to be honest: We can use it like that - it's quite a simple solution and grid is supported of almost 92% of every browser. In the case grid is used, I suggest adding the ms-prefix for a wider support.

The question is, should classless ship a default sticky footer or not. I find no reason to say no. Any further thoughts on that?

@HelloLudger
Copy link
Author

HelloLudger commented Apr 20, 2022

How about

body { display: grid; min-height: 100vh; }
body > footer { align-self: end; }

This seems to have all desired properties. However, I am not sure whether grid on the body has any negative side effects.

Doing this vertically centered my main element. (For years, vertically centering anything was my dream in CSS, now it happens by mistake...)
My solution for now was to add

header {
    display: contents;
}

@firdaus-aziz
Copy link

From my understanding, grid is for a different use case. But to be honest: We can use it like that - it's quite a simple solution and grid is supported of almost 92% of every browser. In the case grid is used, I suggest adding the ms-prefix for a wider support.

The question is, should classless ship a default sticky footer or not. I find no reason to say no. Any further thoughts on that?

For desktop, either sticky or non-sticky is OK.

But for mobile, sticky footer makes so much sense.

That is just my own personal and humble opinion. No statistic/data to back me up.

P/S: this CSS library rocks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants