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;
}