Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Vertically Aligning a's in div with unknown height css

making the navbar of my site a problem occured when I added the logo and my a’s floated to the top of the nav enter image description here

I tried using flexbox like this
display:flex; align-items:center;
on the topnav class but the a’s keep going to the left with the logo

My desired result is to have the a’s on the left and vertically centered

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

.logo {
  margin: 7px;
  margin-left:21px;
  cursor: pointer;
  width: 70px;
  height:auto;
}

.topnav {
  border: 1px solid red;
  color:black;
  background-color:white;
  overflow: hidden;
}

.topnav a {
  margin: 7px;
  padding: 70px 0;
  float: right;
  display: block;
  color: black;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}
<div class="topnav" id="myTopnav">
  <img href="Sindex.php" class="logo" src="Logo.png" alt="logo">
  <a href="#contact">Sign-in/up</a>
  <a href="#news">Order</a>
  <a href="#home" class="active">About</a>
  <a href="javascript:void(0);" class="icon" onclick="myFunction()">
    <i class="fa fa-bars"></i>
  </a>
</div>

>Solution :

Try wrapping your <a>‘s inside a div

and then add to your topnav class:

display: flex;
justify-content: space-between;
align-items: center;

it should work.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading