Implementing text overlays on images within a Bootstrap 4 navigation bar

I am struggling to grasp the flex structure in Bootstrap. I'm attempting to overlay text on an image within the navbar, but it seems the container of the navbar is causing issues. Perhaps my containers are not set up correctly. Any assistance would be greatly appreciated.

Code:

.navbar-brand {
  position: absolute;
  width: 100%;
  z-index: 3000;
}

.mnav {
  height: 123px;
  z-index: 2000;
  width: 1200px
}

.has-bg-img {
  z-index: 2000;
}
   

<div class="section fixed-top">
  <div class="container-fluid bg-dark">
    <div class="row p-3 bg-dark mx-auto ">
      <div class="container text-light" style="max-width: 1200px">topnav</div>
    </div>
  </div>

  <div class="container-fluid bg-light d-flex shadow-lg">
    <nav class="navbar  navbar-expand-lg navbar-light bg-light mx-auto mnav">
      <div class="navbar-collapse collapse w-30 order-1 order-md-0 dual-collapse2">
        <ul class="navbar-nav mr-auto h-dark">
          <li class="nav-item active ">
            <a class="nav-link text-dark" href="#">Home</a>
          </li>
          <li class="nav-item  ">
            <a class="nav-link text-dark" href="//codeply.com">Clinic</a>
          </li>
          <li class="nav-item">
            <a class="nav-link text-dark" href="#">Services</a>
          </li>
          <li class="nav-item">
            <a class="nav-link text-dark" href="#">Gallery</a>
          </li>
          <li class="nav-item">
            <a class="nav-link text-dark" href="#">Blog</a>
          </li>
        </ul>
      </div>



      <div class="col-auto  mx-auto">
        <div class="shadow rounded-circle">
          <img src="https://i.imgur.com/swpgs2N.png" class="img-circle navbar-brand p-0 m-0" alt="marmarasmile-logo">
        </div>
      </div>


      <div class="mx-5 order-0">
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".dual-collapse2">
                             <span class="navbar-toggler-icon"></span>
                        </button>
      </div>




      <div class="navbar-collapse collapse w-30 order-1 order-md-0 dual-collapse2">
        <ul class="navbar-nav mr-auto h-dark">
          <li class="nav-item active ">
            <a class="nav-link text-dark" href="#">Home</a>
          </li>
          <li class="nav-item">
            <a class="nav-link text-dark" href="#">Blog</a>
          </li>
        </ul>
      </div>

      <div class="row pt-4   d-flex align-items-center">
        <div class="col-3  text-white ">
          <span class="navbar-toggler-icon"></span>

          <h5>Appointment</h5>
          <h5>Now !</h5>
          <img src="https://i.imgur.com/4m0eRiP.png" class="img-circle navbar-brand p-0 m-0" alt="marmarasmile-logo">

        </div>
      </div>




    </nav>


  </div>
</div>

<script src="js/jquery-3.x-git.slim"></script>
<script src="js/bootstrap.min.js"></script>

Answer №1

If you need to place your text over an image, check out this helpful article: https://www.w3schools.com/howto/howto_css_image_text.asp

To implement this in your code, you can utilize the following code snippet (I included font-awesome as a placeholder for your icon source):

.bookmark {
  position: relative;
  text-align: center;
  color: white; 
}

.bookmark-texts {
  padding: 20px;
  position: absolute;
  top: 0;
  left: 0;
  font-size: 18px;
}

.fa {
  font-size: 35px !important;
  margin-bottom: 5px;
}

.now {
  font-style: italic;
  font-weight: bold;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css" rel="stylesheet"/>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>
<div class="row pt-4 d-flex align-items-center">
  <div class="col-3">   
    <div id="bookmark" class="d-inline-block">
      <img src="https://i.imgur.com/4m0eRiP.png" class="img-circle navbar-brand p-0 m-0" alt="marmarasmile-logo">
      <div class="bookmark-texts text-center text-white">
        <!-- <span class="navbar-toggler-icon"></span> -->
        <i class="fa fa-calendar" aria-hidden="true"></i>
        <div class="appointment">Appointment</div>
        <div class="now">Now !</div>
      </div>
    </div>
  </div>
</div>

Take a look at this fiddle for a visual representation:

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

How can I generate a checkbox in a database with a field that allows for enabling and disabling?

I am looking to design a table that includes questions, checkboxes, and text boxes. All the questions are stored in a database and called through an array. In addition, I want to create disabled textboxes that become enabled when their corresponding checkb ...

jQuery - class remains unchanged on second click event

Operations: Upon clicking on an element with the class thumb_like or thumb_unlike, a like will be added or removed for the image using a POST request. The element with the class thumb_count will increase or decrease based on user actions. For example, lik ...

Having Trouble Styling Radio Buttons with CSS

Hello, I'm facing an issue with hiding the radio button and replacing it with an image. I was successful in doing this for one set of radio buttons, but the second set in another row is not working properly. Additionally, when a radio button from the ...

Error encountered when attempting to reinitialize DataTable while iterating through multiple tables and searching within tabs

Currently, I am utilizing DataTable to display 3 separate tables with the help of tabs, along with a search function. However, every time I load the page, I encounter a reinitialization error. Here is the snippet of my code: _datatables.forEa ...

Issues with the code: $("input[type=checkbox]:checked").each(function() { var checkboxId = $(this).attr("id"); });

When submitting a form, I need to retrieve the IDs of all checked checkboxes. Currently, $(this).id() is causing an error. What is the correct code to obtain the IDs of all checked checkboxes? $("#pmhxform input:checkbox:checked").each(function() { ...

Show the checked options retrieved from controller

I am facing an issue with displaying certain checkbox values from the controller. In order to properly save these values, I believe it would be best to declare them in the controller and then use them in the HTML. However, my current code is not successful ...

Implement responsive data tables by setting a specific class for hiding columns

Having trouble assigning a specific class name to individual columns in datatables? It seems that when columns are hidden using the responsive extension, the desired class is not applied. Looking for a solution or workaround. Check out this example from D ...

Ensure that FlexBox Columns have a height of 100% and vertically align their content

Having scoured through numerous questions and answers, I'm still stuck on why I can't achieve 100% height for certain flexbox columns. Specifically, trying to make the "Genre" column with one line of text match the height of the "Song & The A ...

Firefox inexplicably splits words in haphazard locations

Although I know about this question, the solution provided doesn't seem to work for me Firefox word-break breaks short words at random points Despite applying the recommended CSS property as shown in the screenshot, it appears that the latest versio ...

Influence of External Style Sheet not reflected in HTML

Just as the title suggests, I have an external style sheet connected to my HTML document, and it appears that the footer element may be incorporating the changes, but none of the other content is. Being new to this, I'm trying to pinpoint where I went ...

The border in my HTML table is not displaying when I run my flask application

My flask application was running smoothly in a virtual environment until I encountered an issue with the html borders not showing up. Even after seeking help from a friend who knows some html, the problem still persists. app.py: from flask import Flask, r ...

What is the best way to implement a JavaScript pattern matching for both "aaaa" and "aaa aaa"?

Can anyone help me create a pattern that can accept both strings with spaces and without spaces in the same text box? I would appreciate any guidance on how to achieve this. Thanks! ...

ScrollReveal.js won't function as intended

https://i.stack.imgur.com/SOQEk.png Looking to utilize the popular ScrollReveal.js created by Julian Lloyd (ScrollReveal) Despite following instructions from various sources, the script is not producing the intended effect. Steps taken to make it work: ...

Mastering the Art of Effortless Content Manipulation with Jquery's

Click here to access the example JSFiddle. I experimented with drag and drop functionality by successfully dragging the word "hello" into a specific div tag. Now, I am wondering how to extend this capability to multiple div tags. How can we achieve dropp ...

submit a new entry to add a record to the database

Hey there, I recently started learning PHP and JS and I'm trying to insert a row into a WordPress database table. I need to get the information needed for insertion from another table, but I'm facing an issue with the PHP file as it's not in ...

Arrange the header and input within a div using flexbox to achieve different alignments

I need help aligning the header section vertically and ensuring responsiveness. Using margin-top isn't fully responsive, so I want to align the header at the beginning of the input field. { margin: 0px; padding: 0px; color: white; } #h ...

How to insert space after every item generated by ng-repeat in AngularJS

I'm looking to evenly distribute elements based on this inquiry How to distribute li elements equally? I am utilizing angular with jade: ul li(ng-repeat="item in items") {{item.name}} However, ng-repeat does not create newlines after each element ...

issues with the handler not functioning properly in html and javascript

<form method="post" action="."> <label class="input-label">Enter Your First Name</label><input field="first_name" class="input-edit" maxlength="30" type="text" value="{{ user.first_name }}" /> <label class="i ...

Replace the image source with a list of images

I am looking to create a dynamic image list using either an array or an HTML list. When I hover over an image, it should change one by one with a fade or slide effect, and revert back to the default images when I hover out. Question 1: What type of list s ...

Is there a way to randomly change the colors of divs for a variable amount of time?

I have a unique idea for creating a dynamic four-square box that changes colors at random every time a button is clicked. The twist is, I want the colors to cycle randomly for up to 5 seconds before 3 out of 4 squares turn black and one square stops on a r ...