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.

https://i.sstatic.net/r4TIk.jpg

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:

https://i.sstatic.net/DSiv2.png

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

Clicking the save button in the modal updates the text on both the current tab and any previously clicked tabs

I'm looking to implement tabs that, when clicking on the edit icon, open a modal for editing the content of each tab. The issue I'm currently encountering is that if I open the editor for one tab, close it without saving, then open the editor fo ...

The code, which is the same, placed in a different location on another page - fails to function

On the index.php page, I have successfully implemented the following code snippet at the bottom: <script type='text/javascript'> $("#tbAlegro").click(function() { window.location = 'alegro.php'; }); </script> However, ...

Reveal the table only once a search has been completed

Currently, I am in the process of developing a small project and my aim is to have the table with the results appear only upon clicking the button or initiating a search. If you are interested, you can view it at this link: . My objective is to keep the t ...

What is the best way to locate and list all video links, and include options for "Play Video" and "Download Video"?

I have a project where I am using PHP to crawl and generate video links from the web. Now, I am looking to implement an option for users to either "Play Video" or "Download Video" when a video link is detected, along with adding a video player if the user ...

Need assistance with CSS layout: How to extend a div to the bottom of the page

I am currently working on a design layout that includes a 'header' section with a logo and links, as well as a content area that should extend to the bottom of the page. However, I am facing some challenges in achieving this. Initially, I enclos ...

Using getServerSideProps in Next.js is preventing the global css from loading

In my Next.js application, I have defined global styles in the file /styles/globals.css and imported them in _app.tsx. // import default style import "../styles/globals.css"; function MyApp({ Component, pageProps }) { return <Component {...pageProps ...

Tips for ensuring a consistent highlight for an active link in Bootstrap

Does anyone have a solution for maintaining highlighted links on a web page? <div id="productnav"> <nav> <ul class="nav"> <li><a href="<?php echo $prefix; ?>pages/one.php?category=1" id="navelement1"<?php if ($c == 1) e ...

What is the best way to display breadcrumb text on a new line within a pop up when the width exceeds without resorting to a scroll bar

Presently, my breadcrumb has a scrollable wrap with text overflow I want to make the overflowed text continue on the next line. How can I achieve this? The CSS code I am using for the image attached is as follows: .breadcrumb-css { text-overflow: ellip ...

The dimensions of the background for a span element

I have a span element with a background-color applied to it. Is there a way to adjust the size of this specific background? I attempted using background-size: auto 2px;, but it did not produce the desired effect. I am looking to make the background color ...

What is the best way to sort ng-options in an AngularJS select element?

I am encountering a situation where I have the following code snippet: <select ng-model="person" ng-options="person.name for person in mv.people"> However, within the mv.people array, there are certain members that I need to hide. For examp ...

Consistent manipulation of the DOM through the Drag/Touchmove event

Seeking to incorporate Mobile Components through native Javascript and AngularJS. During my work on developing a Pull To Refresh directive for AngularJS, I utilized the touchmove event on a UL list. The goal was to pull a concealed div over a list with cu ...

The jQuery panel slider magically appears when you click the button, but refuses to disappear

One issue I am facing on my webpage involves a button that triggers a right panel to open using the jquery and modernizr frameworks. The button is positioned at the far right of the screen. When clicked, it slides to the left along with the panel it reveal ...

What is the best way to showcase a full-screen overlay directly inside an iFrame?

As I work in HTML, I'm faced with a challenge - my iFrame is only taking up a small section of the screen (referred to as 'World' in the example below). What I want to achieve is creating a full-screen div overlay from that iFrame, but curr ...

The format provided is not utilized by Datetimepicker

I've encountered an issue with the Date Time Picker provided by JQuery. Despite setting a specific format, it seems to be using its default date format which results in the following error appearing in the console: Uncaught TypeError: F.mask.replace i ...

The debate between utilizing CDN or installing a library through NPM

My journey with NPM has just begun, and I am struggling to grasp how the files within node_modules get integrated into my index.html. Scenario 1: CDN Take jQuery, for instance. When using a CDN, it's as simple as adding the CDN link to a <script& ...

Single parallax movement determined by the position of the mouse cursor, with no margins

Recently came across this interesting code snippet [http://jsfiddle.net/X7UwG/][1]. It displays a parallax effect when moving the mouse to the left, but unfortunately shows a white space when moving to the right. Is there a way to achieve a seamless single ...

Bootstrap resource failed to load

I successfully connected the most recent version of bootstrap.min.css to my webpage using <link rel="stylesheet" href="assets/css/bootstrap.min.css">. Initially, everything was running smoothly. However, I now encountered an issue where my browser is ...

Is there a way to shift the map to the right side without disrupting the text placement?

please provide image description Here is the code snippet: <div class="row w-100"> <div class="col-lg-6 my-4 offset-lg-1"> <iframe src="#" width="600" height=&q ...

Problem with loading image from local path in Angular 7

I'm having trouble loading images from a local path in my project. The images are not rendering, but they do load from the internet. Can someone please help me figure out how to load images from a local path? I have already created a folder for the im ...

What are some effective strategies for preventing CSS duplication?

What is the best way to prevent repeating CSS code like this: div#logo div:nth-child(1) div { width: 30%; height: 30%; background-color: white; } div#logo div:nth-child(3) div { width: 30%; height: 30%; background-color: white; ...