简体   繁体   中英

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达到这个样子

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在此处输入图像描述

This is the code snippet I followed:

  <div class="container-fluid">
    <a class="navbar-brand" href="#">
      <img src="/docs/5.2/assets/brand/bootstrap-logo.svg" alt="" width="30" height="24" class="d-inline-block align-text-top">
      Bootstrap <br> subheading
    </a>
  </div>
</nav>```

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM