CSS CSS Layout Basics Getting Started with CSS Layout Creating a Sticky Footer

Christine Mackay
Christine Mackay
2,580 Points

Sticky footer sticks to bottom but scrollbar is still there (i.e. the footer is too far down the page).

I followed this video that uses the calc() function to add this to my CSS code:

.wrap { min-height: calc(100vh - 89px); }

However, the footer is still too low down, despite having minused 89px. My scrollbar is still there and I have to scroll down slightly to see the rest of the footer. It's stuck too low. I've tried changing the number of pixels I minus from the 100vh, and it moves the footer up a bit, but I really want to know why the code in the video is not working.

KRIS NIKOLAISEN
KRIS NIKOLAISEN
Pro Student 49,922 Points

Can you post a snapshot? Click the camera icon in the upper right corner, click 'Take Snapshot' and then post the link that is created here.

1 Answer

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 49,922 Points

Here is a snapshot using the workspace from the video

In your css under

/* ================================= 
  Base Element Styles
==================================== */

you are missing a rule for p:last-child

p:last-child {
    margin-bottom: 0;
}

and under

/* ================================= 
  Base Layout Styles
==================================== */

the rule for .main-header has

padding: 1.5em 0;

instead of

padding: 1em 0;

With those changes the footer should appear correctly

Christine Mackay
Christine Mackay
2,580 Points

Thanks :-) It worked but I don't understand why those things need to be changed. I didn't even write the CSS file, only the calc() bit, the rest is what was given to us in the workshop, and the given CSS given worked just fine in the video without the changes you mentioned.

Could this video just be outdated or something? Or the workplace was given to us with errors?