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

I can't vertical align icons in anchor tags

I want to align icons inside this nav-bar. I tried to align them with flexbox, vertical align, etc. I tried everything, but it doesn’t seem to work. Should I rewrite the code inside a list?

The current Code looks like this:

.nav-bar {
  display: flex;
  flex-direction: column;
  position: relative;
}
<div class="container">
  <div class="nav-bar">
    <img src="assets/Ics/....svg"><a routerLink="..">Car</a>
    <img src="assets/Ics/...svg"><a routerLink="..">Make</a>
    <img src="assets/Ics/...svg"><a routerLink="..">About</a>
  </div>
</div>

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

>Solution :

You need to keep your img and anchor tag in flex container with align-items property

<div class="nav-bar">
  <div><img src="assets/Ics/....svg" ><a routerLink="..">Car</a></div>
  <div><img src="assets/Ics/...svg"><a routerLink="..">Make</a></div>
  <div><img src="assets/Ics/...svg"><a routerLink="..">About</a></div>
</div>
.nav-bar div{
  display:flex;
  align-items: center;
}
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