Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS CSS Flexbox Layout Flexbox Properties Vertical and Horizontal Centering

Alex Thomas
Alex Thomas
4,247 Points

why is my justify content pushing everything to the left of the page?

1 Answer

David Brener
David Brener
3,794 Points

Alex,

In Flexbox, if you're looking to place items in a column, you need to use align-items:center;

Please check out the code below...

The HTML

<div class="container">
  <div class="header item">Bo's Motor Works Inc.</div>
  <div class="address item">1836 East 6th Street, Tempe, AZ 85281</div>
  <div>
    <a href="contact.html"><img src="../img/logo14.png" class="logo"></a>
  </div>
  <footer class="footer item">
    <p>&copy; 2017 Alex Thomas</p>
  </footer>
</div>

The CSS

* {
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0px;
  padding: 0px;
  overflow-x: hidden;
}

body {
  background-image: linear-gradient(#2e9bda, black);
  background-size: cover;
  background-repeat: no-repeat;
}

.container {
  display: flex;
  min-height: 50vh;
  flex-direction: column;
  align-items: center;
  flex-wrap: wrap;
}

.header {
  font-family: Dancing Script;
  font-size: 2em;
}