I’m running into some issues with my code. I have a nav bar in my header that I am trying to add some space between. I would like my links on one side of the header and my company name on the other. However, when I do space-between it puts my links to the center of the page. I previously had a materials icon in my header as well but I sat the display to none (until it meets the condition of my media query) which I thought would solve the issue but it has not. Any advice on solving this issue?

/* Site-wide */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  /* height: 100%; */
}


/* Header */

header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  background-color: lightgray;
  align-items: center;
  padding: 0px 0px 5px 5px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
}

.logo {
  font-size: 2vh;
}

header a {
  text-decoration: none;
  color: white;
  padding-right: 10px;
}

.material-icons {
  display: none;
}


/* Main */

main {
  display: flex;
  padding-left: 5px;
  margin-top: 50px;
  flex-wrap: wrap;
  /* justify-content: space-around; */
}

.card {
  border: 1px solid black;
  height: 350px;
  width: 300px;
  /* margin: 5rem; */
  margin: 0 20px 2rem 5px;
  background-color: rgba(211, 211, 211, 0.251);
}

.card h3 {
  background-color: rgba(185, 44, 185, 0.803);
  padding-left: 3px;
}

.card p {
  padding-left: 5px;
}


/* Footer */

footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: lightgray;
  text-align: center;
}


/* Media Queries */

@media(max-width:768px) {
  .hamburger {
    display: none;
  }
  .material-icons {
    display: block;
  }
  main {
    display: flex;
    flex-wrap: wrap;
  }
  .card {
    flex-basis: auto;
  }
  .card h3,
  p {
    font-size: 20px;
  }
}
<!DOCTYPE html>
<html>

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
  <link rel="stylesheet" href="media.css">
</head>

<body>
  <header>
    <span class="logo">Company Name</span>
    <nav>
      <a href="">Link One</a>
      <a href="">Link Two</a>
      <a href="">Link Three</a>
    </nav>
    <a class="hamburger"><i class="material-icons">menu</i></a>
  </header>
  <main>
    <div class="card">
      <h3>Card Title</h3>
      <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Voluptates, dolor eveniet consequatur aliquid id quo quam architecto accusantium ipsam et officia temporibus nesciunt hic officiis totam fugiat doloremque iusto amet.</p>
    </div>
    <div class="card">
      <h3>Card Title</h3>
      <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Voluptates, dolor eveniet consequatur aliquid id quo quam architecto accusantium ipsam et officia temporibus nesciunt hic officiis totam fugiat doloremque iusto amet.</p>
    </div>
    <div class="card">
      <h3>Card Title</h3>
      <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Voluptates, dolor eveniet consequatur aliquid id quo quam architecto accusantium ipsam et officia temporibus nesciunt hic officiis totam fugiat doloremque iusto amet.</p>
    </div>
    <div class="card">
      <h3>Card Title</h3>
      <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Voluptates, dolor eveniet consequatur aliquid id quo quam architecto accusantium ipsam et officia temporibus nesciunt hic officiis totam fugiat doloremque iusto amet.</p>
    </div>
    <div class="card">
      <h3>Card Title</h3>
      <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Voluptates, dolor eveniet consequatur aliquid id quo quam architecto accusantium ipsam et officia temporibus nesciunt hic officiis totam fugiat doloremque iusto amet.</p>
    </div>
    <div class="card">
      <h3>Card Title</h3>
      <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Voluptates, dolor eveniet consequatur aliquid id quo quam architecto accusantium ipsam et officia temporibus nesciunt hic officiis totam fugiat doloremque iusto amet.</p>
    </div>
  </main>
  <footer>
    Copyright 2009
  </footer>
</body>

</html>

jbrown023 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

2

Specify margin-left: auto; on nav.

/* Site-wide */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  /* height: 100%; */
}


/* Header */

header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  background-color: lightgray;
  align-items: center;
  padding: 0px 0px 5px 5px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
}

.logo {
  font-size: 2vh;
}

header a {
  text-decoration: none;
  color: white;
  padding-right: 10px;
}

.material-icons {
  display: none;
}


/* Main */

main {
  display: flex;
  padding-left: 5px;
  margin-top: 50px;
  flex-wrap: wrap;
  /* justify-content: space-around; */
}

.card {
  border: 1px solid black;
  height: 350px;
  width: 300px;
  /* margin: 5rem; */
  margin: 0 20px 2rem 5px;
  background-color: rgba(211, 211, 211, 0.251);
}

.card h3 {
  background-color: rgba(185, 44, 185, 0.803);
  padding-left: 3px;
}

.card p {
  padding-left: 5px;
}


/* Footer */

footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: lightgray;
  text-align: center;
}


/* Media Queries */

@media(max-width:768px) {
  .hamburger {
    display: none;
  }
  .material-icons {
    display: block;
  }
  main {
    display: flex;
    flex-wrap: wrap;
  }
  .card {
    flex-basis: auto;
  }
  .card h3,
  p {
    font-size: 20px;
  }
}

nav {
  margin-left: auto;
}
<!DOCTYPE html>
<html>

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
  <link rel="stylesheet" href="media.css">
</head>

<body>
  <header>
    <span class="logo">Company Name</span>
    <nav>
      <a href="">Link One</a>
      <a href="">Link Two</a>
      <a href="">Link Three</a>
    </nav>
    <a class="hamburger"><i class="material-icons">menu</i></a>
  </header>
  <main>
    <div class="card">
      <h3>Card Title</h3>
      <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Voluptates, dolor eveniet consequatur aliquid id quo quam architecto accusantium ipsam et officia temporibus nesciunt hic officiis totam fugiat doloremque iusto amet.</p>
    </div>
    <div class="card">
      <h3>Card Title</h3>
      <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Voluptates, dolor eveniet consequatur aliquid id quo quam architecto accusantium ipsam et officia temporibus nesciunt hic officiis totam fugiat doloremque iusto amet.</p>
    </div>
    <div class="card">
      <h3>Card Title</h3>
      <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Voluptates, dolor eveniet consequatur aliquid id quo quam architecto accusantium ipsam et officia temporibus nesciunt hic officiis totam fugiat doloremque iusto amet.</p>
    </div>
    <div class="card">
      <h3>Card Title</h3>
      <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Voluptates, dolor eveniet consequatur aliquid id quo quam architecto accusantium ipsam et officia temporibus nesciunt hic officiis totam fugiat doloremque iusto amet.</p>
    </div>
    <div class="card">
      <h3>Card Title</h3>
      <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Voluptates, dolor eveniet consequatur aliquid id quo quam architecto accusantium ipsam et officia temporibus nesciunt hic officiis totam fugiat doloremque iusto amet.</p>
    </div>
    <div class="card">
      <h3>Card Title</h3>
      <p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Voluptates, dolor eveniet consequatur aliquid id quo quam architecto accusantium ipsam et officia temporibus nesciunt hic officiis totam fugiat doloremque iusto amet.</p>
    </div>
  </main>
  <footer>
    Copyright 2009
  </footer>
</body>

</html>

Not the answer you’re looking for? Browse other questions tagged html css flexbox or ask your own question.