Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS

Amanda Bater
Amanda Bater
7,686 Points

Sticky Footer with Flexbox

I just watched the sticky footer with flexbox tutorial and when I tried to apply what I'd learned to my own project it hasn't worked...can anyone tell me why this is?

html

<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Toby Dashwood Editing</title>
    <script src="script.js"></script>
    <link rel="stylesheet" href="css/normalize.css">
    <link rel="stylesheet" href="css/main.css">

  </head>

  <body id="top">
    <div class="wrap">
    <header class="main-header">

          <h1 class="name"><a href="index.html">Toby Dashwood Editing</a></h1>
          <ul class="main-nav">
            <li><a href="about.html">About</a></li>
            <li><a href="contact.html">Contact</a></li>
          </ul>
      </header>

    <div class="banner">
      <section>
        <img class="gif" src="img/Final-Cut-Pro004.gif" alt="Final Cut Gif">
      </section>
    </div>

    <div id="container">
      <section>



      </section>

    </div>
    </div>
    <footer>
        <h3>Social</h3>
        <a href="https://twitter.com/tobycdash" target="_blank"><img src="img/twitter-wrap.png" alt="Twitter Logo" class="social-icon"></a>
        <a href="https://vimeo.com/tobydashwood" target="_blank"><img src="img/vimeo-wrap.png" alt="Vimeo Logo" class="social-icon"></a>
        <a href="https://www.linkedin.com/in/toby-dashwood-58105316" target="_blank"><img src="img/linked-wrap.png" alt="LinkedIn Logo" class="social-icon"></a>
        <p>&copy; 2016 Toby Dashwood Editing.</p>
        <div class="scroll">
          <a href="#top" onclick="scrollToTop();return false"><img src="img/backtotop.png" alt="scroll"></a>
        </div>
      </footer>

  </body>
  </html>

css

/******************************
GENERAL
******************************/

/*
* {
  border: 1px solid red;
}
*/

body {
  font-family: "Montserrat","Open Sans","Arial",sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#container {
  flex: 1;
}

a {
  text-decoration:none;
}

img {
  max-width: 100%;
}

.top {
 width: 20px;
 height: 20px;
}

/******************************
CONTAINER
******************************/
#container {
  padding-left: 5%;
  padding-right: 5%;
  margin: 50px auto;
}



a, a:visited {
 color: #222222;
}

/******************************
HEADING
******************************/

.name {
  text-align:center;
  margin: 0;
}
.name a {
  padding-left: 10px;
  padding-right: 10px;
  display: block;
}

.main-header {
/*  margin: 45px 0 30px 0;*/
  padding: 45px 0 30px 0;
  width: 100%;
  background-color: #fff;
}


h1 {
  color: #222222;
  text-transform: uppercase;
  font-family: "Montserrat","Open Sans","Arial",sans-serif;
  font-weight: 100;
  font-size: 1.5em;
  line-height: 1.2em;
}

/******************************
NAVIGATION
******************************/

.main-nav {
  text-align: center;
  padding:5px 10px;
  margin: 0;
  font-family: "Montserrat","Open Sans","Arial",sans-serif;
  font-size: .8em;
  text-transform: uppercase;
  list-style-type: none;
}

.main-nav li {
  margin-top: 8px;
  margin-bottom: 8px;
}

.main-nav a {
  font-weight: normal;
  padding-left: 15px;
  padding-right: 15px;
  display: block;
}

.main-nav a.selected, .main-nav a:hover {
  color: #ffae00;
}

.main-nav li a.current {
  color: #ffae00;
}





/******************************
PAGE:ABOUT
******************************/

h3 {
  font-size: 0.8em;
  font-weight: normal;
  text-align: center;
}

p {
  font-size: 0.8em;
  font-weight: 50;
}

/******************************
PAGE:CONTACT
******************************/


.contact-info {
  list-style-type: none;
  text-align: center;
  padding: 0;
}



.contact-info img {
  border-radius: 100%;
  width: 80px;
  height: 80px;
}

.contact-info h3 {
  text-transform: uppercase;
}

.contact-info p {
  font-size: 0.8em;
  line-height: 1.8em;
}

/******************************
PAGE:FOOTER
******************************/

footer {
  font-size: 0.7em;
  text-align: center;
  clear: both;
  padding-top: 50px;
  padding-bottom: 30px;
  padding-left: 30px;
  color: white;
  background-color: #222222;

}

footer h3 {
  text-transform: uppercase;
  text-align: center;
}

  .social-icon {
    width: 30px;
    height: 30px;
    margin: 0 5px;
  }

.scroll img {
  height: 20px;
  width: 20px;
}

.scroll {
  margin-top: 20px;
}

/******************************
MEDIA QUERIES
******************************/

@media (min-width: 769px) {



#container {
  max-width:85%;
  margin: 50px auto;
  padding: 0 10%;
}

.main-header,
.main-nav {
  display: flex;
}

.main-header {
  flex-direction: column;
  align-items: center;
}

.main-nav {
  justify-content: center;
}


.contact-info li {
  display: inline-block;
  width: 25%;
  vertical-align: top;
  padding-right: 20px;
  padding-left: 20px;
}



}

@media (min-width: 1025px) {
  .main-header {
  flex-direction: row;
  justify-content: space-between;
}
}

@media (min-width: 1436px) {

body,
.main-header {
  max-width: 1436px;
}

}

2 Answers

Hi,

I stuck the code up on codepen and all I had to do was ad margin-top: auto; to the footer and it worked.

http://codepen.io/Craig-Watson/pen/jqwMEy?editors=1100

Take a peak I will leave it live for a little while till you have a look.

Craig