How to add 2 texts next to logo in Bootstrap Navbar

Viewed 50

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>

2 Answers

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>

Include subheading into span and add to it position:reltive to control to it from left and top

nav .navbar-brand span{
  position:relative;
  top:30px;
  left:-90px;
  color:red;
 }
<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 <span> subheading </span>
        </a>
      </div>
  </nav>
  

Related