Placing two texts alongside a logo in a Bootstrap Navbar: Step-by-step guide

As I venture into the world of Bootstrap, I am on a quest to create a Navbar Component similar to this design:

https://i.stack.imgur.com/NidKQ.png

I attempted to use the Navbar Image and Text code, but encountered an issue where the text would only display in a single line. I tried inserting a line break, but then the text went below the logo resulting in a layout like this:

https://i.stack.imgur.com/Wy0jE.png

Here is the snippet of code that I referenced:

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b9dbd6d6cdcacdcbd8c9f98c978b9789">[email protected]</a>/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>

Answer №1

Here is a suggestion for you:

<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="84d6dbdbe0e7e0e6f5e4d4a1baa6baa4">[email protected]</a>/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>

Answer №2

Insert subheading inside a span element and apply position:relative to control its position from the left and top

nav .navbar-brand span{
  position:relative;
  top:30px;
  left:-90px;
  color:red;
 }
<link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d3b1bcbca7a0a7a1b2a393e6fde1fde3">[email protected]</a>/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>
  

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

"Discover a unique online platform showcasing videos and images with a creative

I recently updated my personal website to showcase some of the tools I've developed through short looping videos. Initially, everything was working well with just images, but when I switched to videos, I encountered some unexpected behaviors. Interest ...

What is the secret to the lightning speed at which this tag is being appended to the DOM?

Have a look at this concise sandbox that mirrors the code provided below: import React, { useState, useEffect } from "react"; import "./styles.css"; export default function App() { let [tag, setTag] = useState(null); function chan ...

Ways to create gaps between rows of a table

I have been attempting to replicate the layout of this table: However, I am running into an issue with the spacing between the rows (border-spacing: 0 2px), and I'm not sure why. Can anyone provide any guidance on this? This is the code I am using: ...

Using Django and Jquery to pass multiple values to HTML, with one value stored in a .js file

Here is an example of HTML code: {% for m in mortgages %} <input id ='mortgages_counter' name='mortgages_counter' type='hidden' value='{{ m.MonthlyPaid }}'> {% endfor %} If used for a selection menu: {% for ...

Achieve vertical center alignment of items using flexbox styling

I'm attempting to vertically center elements using CSS flexbox. I have successfully implemented it with the non-vendor-prefixed code, but I am facing issues in Webkit (Chrome) even with the vendor prefixes. My goal is to vertically align the spans wi ...

What is the best way to customize the appearance of a non-current month cell within the date picker?

I'm currently in the process of developing a registration form for my JavaFX application. I am faced with an issue where I need to disable certain cells in the date picker when they do not belong to the displayed month. Let's take a look at my cu ...

My goal is to develop a PHP photo gallery using either an array, session variables, or cookies

I am in need of a solution for my issue. https://i.stack.imgur.com/Xe65l.png The image shows the front end, and I require a corresponding function to be developed for it. ...

Modifying SASS variable values based on the presence of specific text in the page URL

How can I utilize the same SASS file for two different websites with similar functionality but different color schemes? My goal is to dynamically change the color based on the URL of the page. However, I am facing challenges in extracting the page URL from ...

Error: Unable to execute $(...).stellar since it is not a recognized function

Having some trouble implementing the stellar plugin. I've included all the necessary js, but keep getting an error in the dev tools console: 'Uncaught TypeError: $(...).stellar is not a function'. Here's what I have in the head tags: ...

jquery-enhanced tabs with versatile functionality

HTML: <ul class="tabs"> <li><a href="#tab-one" class="current">Residential</a></li> <li><a href="#tab-two">Commercial</a></li> <li><a href="#tab-three">Agricultural</a></li> < ...

What is the best way to add color to a Table Header?

I'm working on a HTML/CSS table and I want the header row to have a specific background color. Below is my code: <table class="contentTable"> <tr class="contentTableHeader"> <th>No.< ...

Preventing Past Dates from Being Selected in JQuery Date Picker

Need help with a date picker that only allows selection of the 1st and 15th dates of each month. How can I prevent users from selecting previous dates? <link href="https://code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css" rel="stylesheet" ty ...

The sidebar made an unexpected leap from one side to the other, with no memory of ever tampering

I'm feeling a bit overwhelmed because I can't seem to figure this out. My goal is to create a basic page layout with a header, subheader, sidebar, content pane, and footer. Everything was going smoothly until I started writing a function in my J ...

The renderToString function in Material UI's sx property doesn't seem to have

Every time I apply sx to a component that is rendered as a string and then displayed using dangerouslySetInnerHtml, the styles within the sx prop do not work. Here is an example showcasing the issue: Codesandbox: https://codesandbox.io/p/sandbox/wonderfu ...

Encountering a NaN outcome when summing values from various select options

I'm working on a project that involves adding up the prices based on the surface chosen by the user. I'm struggling with calculating the partial cost when the user's choice changes. totalSum.ts num: Calculation totalAmount: number cate ...

What is the best way to eliminate YouTube branding from a video embedded in a website?

I am currently utilizing an <iframe width="550" height="314" src="https://www.youtube.com/embed/vidid?modestbranding=1&amp;rel=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe> This setup removes the "YouTube" logo from the ...

A step-by-step guide on showcasing three post images in separate divs at the bottom of a webpage with Reactjs and Css

In the array below, there are three post photos. When I click on each post button, I should see a corresponding post photo div at the bottom for each post. Issue: I am facing a problem where only one post photo div is being displayed, which keeps replaci ...

The spacing in the Superfish menu is not aligned correctly

I am encountering a spacing issue with a superfish drop down menu. The problem can be observed here: To view the issue in action, visit this link: Essentially, all of the submenu items are floated left with a 50% width. I am looking for a solution to rem ...

PHP and issues with search functionality

I am currently working on developing a search function to retrieve and display data from a MySQL database based on user selection. However, I encountered an error that I am not sure how to resolve. Can anyone provide assistance? I am fairly new to PHP. The ...

Animating a SVG element within a group tag using the path element

I'm struggling to make a slice of a circle rotate using the :hover selector in CSS. Even though my initial attempt at applying CSS transformations works perfectly, the rotation stops when I introduce the :hover selector. Below is the HTML and CSS co ...