Sticky footer

Sticky footer by using flex

by Eugen Zubkov

HTML

<body>

    <header>
      <div class="wrapper">
        Header content
      </div>
    </header>
  
    <div class="page-content">
      <div class="wrapper">
        Page content
      </div>
    </div>
    
    <footer>
      <div class="wrapper">
        Footer content
      </div>
    </footer>

  </body>

CSS

/**
 * Reset some basic elements
 */
body, h1, h2, h3, h4, h5, h6,
p, blockquote, pre, hr,
dl, dd, ol, ul, figure {
    margin: 0;
    padding: 0;
}


/**
 * Basic styling
 */
body {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
    box-sizing: border-box;
}

/**
 * Header/footer content
 */
header, footer {
    height: 100px;
    width: 100%;
    background-color: #3498db;
    color: #fff;
}


/**
 * Page content
 */
.page-content {
    flex: 1;
}

.wrapper {
  text-align: center;
  line-height: 100px;
}