Jakob Jakob - 1 month ago 10
CSS Question

HTML & CSS - Centering text in header inbetween logo and button

How would i be able to align my navigation links to the header?
This is what i currently have: Link between logo and button
But, I'd really like to have the links vertically aligned within the header, like this: Wanted result.
How would i do this?
Below is my CSS & HTML.



html, body {
margin: 0;
padding: 0;
}

body {
font-family: 'Open Sans', sans-serif;
}

.wrapper {
width: 1100px;
max-width: 90%;
margin: 0 auto;
}

#top_header {
position: fixed;
left: 0px;
top: 0px;
right: 0px;
background-color: #26ABF5;
height: 70px;
vertical-align: middle;
}

#logo_top {
display: inline-block;
width: 53px;
padding-top: 8px;
}

#main_nav {
display: inline-block;
font-size: 12px;
padding-left: 170px;
}

#main_nav a {
color: #fff;
font-weight: 400;
text-decoration: none;
margin-left: 6em;
}

.button {
float: right;
justify-content: center;
display: flex;
width: 101px;
margin-top: 14px;
padding-top: 9px;
padding-bottom: 9px;
border-radius: 2px;
background-color: #fff;
text-decoration: none;
font-family: 'Open Sans', sans-serif;
color: #26abf5;
font-size: 13px;
font-weight: 600;
}

<body>
<header id="top_header">
<div class="wrapper">
<a href="index.html"><img id="logo_top" draggable="false" src="images/logo1.png"></a>
<nav id="main_nav">
<a href="#">FORSIDE</a>
<a href="#">HVAD TILBYDER VI?</a>
<a href="#">PRISER</a>
<a href="#">OM OS</a>
</nav>
<a class="button" href="#">LOG IND</a>
</div>
</body>




Answer

Use line-height for vertical-align. Im add the line in #main_nav.

Edit: add float: left; for your logo image.

html, body {
    margin: 0;
    padding: 0;
}

body {
  font-family: 'Open Sans', sans-serif;
}

.wrapper {
  width: 1100px;
  max-width: 90%;
  margin: 0 auto;
}

#top_header {
  position: fixed;
  left: 0px;
  top: 0px;
  right: 0px;
  background-color: #26ABF5;
  height: 70px;
  vertical-align: middle;
}

#logo_top {
  display: inline-block;
  float: left;
  width: 53px;
  padding-top: 8px;
}

#main_nav {
  display: inline-block;
  font-size: 12px;
  line-height: 70px;
  padding-left: 170px;
}

#main_nav a {
  color: #fff;
  font-weight: 400;
  text-decoration: none;
  margin-left: 6em;
}

.button {
  float: right;
  justify-content: center;
  display: flex;
  width: 101px;
  margin-top: 14px;
  padding-top: 9px;
  padding-bottom: 9px;
  border-radius: 2px;
  background-color: #fff;
  text-decoration: none;
  font-family: 'Open Sans', sans-serif;
  color: #26abf5;
  font-size: 13px;
  font-weight: 600;
}
<body>
    <header id="top_header">
      <div class="wrapper">
        <a href="index.html"><img id="logo_top" draggable="false" src="images/logo1.png"></a>
          <nav id="main_nav">
            <a href="#">FORSIDE</a>
            <a href="#">HVAD TILBYDER VI?</a>
            <a href="#">PRISER</a>
            <a href="#">OM OS</a>
          </nav>
            <a class="button" href="#">LOG IND</a>
      </div>
  </body>