skip to Main Content

I’m having trouble figuring out how to perfectly align my text and image.

Examples:

enter image description here

enter image description here

enter image description here

Any help is appreciated!

.navbar .logo a {
  color: #ececec;
  font-size: 1.5rem;
  font-weight: 700;
}
.logo img {
  width: 30px;
}
<div class="logo">
    <img src="img/favicon/favicon.png" alt="">
    <a href="#">LABFOLD</a>
</div>

2

Answers


  1. Use flex box to align them perfectly

    .logo {
      display: flex;
      align-items: center;
      justify-content: center;
    }
    
    .navbar .logo a {
      color: #ececec;
      font-size: 1.5rem;
      font-weight: 700;
    }
    
    .logo img {
      width: 30px;
    }
    <div class="logo">
      <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/b/b6/Image_created_with_a_mobile_phone.png/1280px-Image_created_with_a_mobile_phone.png" alt="">
      <a href="#">LABFOLD</a>
    </div>
    Login or Signup to reply.
  2. You can use flexbox to do so:

    .logo {
      display: flex;
      align-items: center;
    }
    

    I’d also add some right margin to the image so it’s not sticking with the logo text:

    .logo img {
      width: 30px;
      margin-right: 10px;
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search