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

footer height

Hi, When i check in the console the footer height is not 89px but 112 px.

Also I am still getting a scroll bar when i resize the window.

Thanks

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

* {
  box-sizing: border-box;
}

body {
    line-height: 1.6;
    color: #3a3a3a;
}

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

a { 
    color: #fff;
    text-decoration: none;
}

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

/* ---- Navigation ---- */

.name {
  margin: 0;
}

/* ---- Layout Containers ---- */

.container {
  padding-left: 1em;
  padding-right: 1em;
}

.main-header {
    padding: 1.5em 0;
    background: #3acec2;
}

.main-footer { 
    text-align: center;
    padding: 2em 0;
    background: #d9e4ea;
}

/* ================================= 
  Media Queries
==================================== */

@media (min-width: 769px) {
    .container {
        width: 70%;
        max-width: 1000px;
        margin: 0 auto;
    }
.wrapper{
  min-height:calc(100vh - 89px);
}

1 Answer

Steven Webster
Steven Webster
5,719 Points

If you're using Chrome and you inspect the p within the footer (or any p on the page, for that matter), you'll notice a margin-block-start and margin-block-end value of 1em inherited from the user agent stylesheet.

It seems that this might be a quite recent addition to the user agent stylesheet because it doesn't yet appear in even the most recent version of normalize.css, and Sublime still doesn't have text-highlighting or auto-complete for it!

Anyway, set both of those values to 0 for p elements and 89px will then be the right value to subtract from 100vh.