Body extends below footer

Does anyone know why the body extends below my footer on smaller screens ? and there's no fix height so I don't understand what's going on.. https://codepen.io/Antony-Collin/pen/WNYejKZ
45 Replies
StefanH
StefanH•2y ago
Old vid but this should help https://youtu.be/yc2olxLgKLk
Kevin Powell
YouTube
Easy sticky footer - stop a footer from floating up a short page!
Having the footer of the page just floating around in the middle just looks... bad. So let's see how we can fix it with both flexbox and grid in this video! As an added bonus, both of them are really easy to do! This CSS-Tricks articles has a few other ways, including different ways to do it with flexbox and grid in case you run into issues wit...
QuEEb
QuEEbOP•2y ago
thanks, will check it out
StefanH
StefanH•2y ago
Html is quite devious that way. Your background may extend all the way down, but the actual div or whatever doesn't
QuEEb
QuEEbOP•2y ago
does the video explain how to stop my body at my current footer position or how to stick my footer all the way down my current body ? because I would rather the first option, idk if it's possible tho
StefanH
StefanH•2y ago
What do you mean with "stop the body at your footer position"?
QuEEb
QuEEbOP•2y ago
I would like my full page to be this long instead of just adjusting my footer down
StefanH
StefanH•2y ago
Well, the browser is gonna be as tall as the user wants You cant resize the window. That goes against everything web design is about You could have your content centered at the page
QuEEb
QuEEbOP•2y ago
I'm not sure I understand, I thought the height of the page is as long as it needs to be to fit the content
StefanH
StefanH•2y ago
And then the footer at the bottom. That would make best use of the screen space Yeah. I don't understand what your goal is If the window is taller than your page, it'll just end halfway through
QuEEb
QuEEbOP•2y ago
got you ! I got confused I guess. I will check the video for cases where the window becomes taller
StefanH
StefanH•2y ago
For this page i'd recommend moving the footer down and then centering your content vertically I've made home pages like this before. Works pretty well
QuEEb
QuEEbOP•2y ago
can I just use vertical align to center the content ?
StefanH
StefanH•2y ago
No, that property only applies to text. It doesnt do what you think it does I'd use flex-grow on the middle div to have it fill the vertical space and then use another flex or grid container tk center your content in there Making a codepen one sec
QuEEb
QuEEbOP•2y ago
I fixed the footer now I just need to center the content
QuEEb
QuEEbOP•2y ago
StefanH
StefanH•2y ago
is codepen down? ok ok
/* The thing you applied flex-grow: 1 to */
main {
display: grid;
place-items: center;
}
/* The thing you applied flex-grow: 1 to */
main {
display: grid;
place-items: center;
}
QuEEb
QuEEbOP•2y ago
it works for me
QuEEb
QuEEbOP•2y ago
I don't know what I did wrong but it doesn't seem to fix https://codepen.io/Antony-Collin/pen/WNYejKZ
StefanH
StefanH•2y ago
oh you added margin-top: auto to the footer i prefer using flex-grow for this because then the main content always fills the page
QuEEb
QuEEbOP•2y ago
so flex-grow: 1 for the footer ?
StefanH
StefanH•2y ago
Or actually i've been using grid lately Wait i'll make a codepen
QuEEb
QuEEbOP•2y ago
thanks for your time, I appreciate it
QuEEb
QuEEbOP•2y ago
it kinda works but displays my flexbox vertically
StefanH
StefanH•2y ago
Can you update your codepen? Also probably good to only have a single div in main. just wrap both your divs in an empty div
StefanH
StefanH•2y ago
Also that should be a heading tag of some sort
StefanH
StefanH•2y ago
Doesn't look any different to me?
QuEEb
QuEEbOP•2y ago
I want my flexbox to display it like this but centered, I don't want the items to be vertical
StefanH
StefanH•2y ago
I can't see the changed version on codepen. Still using the old methods for me
QuEEb
QuEEbOP•2y ago
ah, ok oops https://codepen.io/Antony-Collin/pen/WNYejKZ do you see it now ?
StefanH
StefanH•2y ago
Yes
QuEEb
QuEEbOP•2y ago
StefanH
StefanH•2y ago
Issue is you accidentally changed your .games to have display: grid lol That should be flex. Guessing that's a mistake
QuEEb
QuEEbOP•2y ago
you are right, but if I'm not mistaken, .games doesn't seem to be centered
QuEEb
QuEEbOP•2y ago
is it ? idk
StefanH
StefanH•2y ago
No. It doesn't seem like you implemented my suggestions in the codepen
StefanH
StefanH•2y ago
you're still using the giant footer margin here
QuEEb
QuEEbOP•2y ago
I have no idea... I'm trying https://codepen.io/Antony-Collin/pen/WNYejKZ you're there ? @stefanh
StefanH
StefanH•2y ago
this is the stuff you need to replicate
StefanH
StefanH•2y ago
look at my example code and apply it to yours
QuEEb
QuEEbOP•2y ago
I tried and it's not working
vince
vince•2y ago
I wouldn't use vh units here. You can apply height: 100% to html tag and min-height: 100% to body tag Really it shouldn't make a difference in this case I don't think but imo it's better to just completely avoid vh/vw units when you can
StefanH
StefanH•2y ago
vh is perfect for this. note that it's a min-height, not a height i used to set min-height 100% on html and body too but this is faster and i can't see any negative side effects viewport units are often discouraged because people use them for dynamic font sizes, but even then, they're fine as long as you clamp them
vince
vince•2y ago
Yea I agree with you, but I think if someone is new to css it's better to avoid viewport units because it's an easy trap to fall into, since there's a lot of nuances that someone who is new might not know Just my 2 cents
Want results from more Discord servers?
Add your server