Search code examples
htmlcssbootstrap-4bootstrap-5nav

How to add 2 texts next to logo in Bootstrap Navbar


I am starting out with Bootstrap and I am trying to achieve this kind of look with the Navbar Component

achieve this look

I tried using the Navbar Image and Text code, but the text only continues in one line. I tried adding a break but the text will go below the logo. It'll look like this

enter image description here

This is the code snippet I followed:

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">
      <img src="    https://getbootstrap.com/docs/5.2/assets/brand/bootstrap-logo-shadow.png" alt="" width="70" height="70" class="d-inline-block align-text-top">
      Bootstrap <br> subheading
    </a>
  </div>
</nav>


Solution

  • Try this:

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
    
    <nav>
      <div class="container-fluid">
        <div class="d-flex flex-row">
          <a class="navbar-brand navbar" href="#">
            <img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTi65_HIy_en0R9pg-vjBsO3Fi2CFbJ96MtKdGIGjrlXw&s" alt="" width="100">
            <div class="d-flex flex-column p-2 pt-0 pb-0">
              <h1 class="mb-1">Title</h1>
              <p class="mb-1">Subheading</p>
            </div>
          </a>
        </div>
      </div>
    </nav>