The navigation toggler icon seems to be missing from my display, but clicking on the area where it should be still activates it. How can I fix this issue

When I customized the background for the nav-bar in Bootstrap 4 and added a nav-toggler-icon for small screens, I encountered an issue where the hamburger icon was not displaying. However, it worked fine when clicked. How can I resolve this problem? The HTML code snippet is as follows:

<nav id=header-nav class="navbar navbar-expand-md navbar-custom ">
      <a href="index.html" class="navbar-brand">
        <h1 class="tagline">Subha</h1>
      </a>
      <button class="navbar-toggler" data-toggle="collapse" data-target="#hamburger">
            <span class=" navbar-dark navbar-toggler-icon"></span>
        </button>
      <div class="collapse navbar-collapse" id="hamburger">
        <ul class="navbar-nav ml-auto">
        <li class="nav-item">
          <a href="#" class="nav-link">Cart</a></li>
        <li class="nav-item">
          <a href="#" class="nav-link">Login</a></li>
      </ul>
      </div>
    </nav>

The CSS code for the nav bar customization is as follows:

.navbar-custom
{
background-color: rgb(144,12,25);
    border-radius: 0;
    border: 0;
}

Answer №1

Make a simple adjustment:

data-target="#hamburger"

Change it to:

data-target="#navbarResponsive"

If you still need more help, feel free to use my navbar template:

<nav class="navbar navbar-expand-md navbar-light bg-light sticky-top">
        <div class="container-fluid">
            <a href="#" class="navbar-brand"><img src="img/logo.png" alt="Logo" /></a>
            <!-- dropdown btn -->
            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive">
                <span class="navbar-toggler-icon"></span>
            </button>
            <!-- nav-links -->
            <div class="collapse navbar-collapse" id="navbarResponsive">
                <ul class="navbar-nav ml-auto">
                    <li class="nav-item active">
                        <a href="#" class="nav-link">home</a>
                    </li>
                    <li class="nav-item">
                        <a href="#" class="nav-link">about</a>
                    </li>
                    <li class="nav-item">
                        <a href="#" class="nav-link">services</a>
                    </li>
                    <li class="nav-item">
                        <a href="#" class="nav-link">team</a>
                    </li>
                    <li class="nav-item">
                        <a href="#" class="nav-link">connect</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

Answer №2

Your <nav> element is missing the necessary color scheme color class that Bootstrap uses to add the icon to the button.

The issue lies in its placement - the color class should be on the <nav> itself, not on the <span>. Currently, it's only visible when clicked due to an applied outline style.

See below for a demonstration:

body {
  zoom: 2;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">
<div class="navbar-light bg-primary">
  <span class="navbar-toggler-icon"></span>
</div>
<br>
<div class="navbar-dark bg-primary">
  <span class="navbar-toggler-icon"></span>
</div>


To resolve this issue, follow these steps:

.navbar-custom {
  background-color: rgb(144, 12, 25);
  border-radius: 0;
  border: 0;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">

<nav id=header-nav class="navbar navbar-expand-md navbar-dark navbar-custom ">
  <a href="index.html" class="navbar-brand">
    <h1 class="tagline">Subha</h1>
  </a>
  <button class="navbar-toggler" data-toggle="collapse" data-target="#hamburger">
    <span class="navbar-toggler-icon"></span>
  </button>
  <div class="collapse navbar-collapse" id="hamburger">
    <ul class="navbar-nav ml-auto">
      <li class="nav-item">
        <a href="#" class="nav-link">Cart</a></li>
      <li class="nav-item">
        <a href="#" class="nav-link">Login</a></li>
    </ul>
  </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

Undefined value is returned by Ajax request

I am facing an issue with my ajax request: $.ajax({ type:'POST', url:'../php/anmelden_info.php', data:{ kat : 'Freizeitfussballer' }, success: function(data){ alert(data[0].anmelde_info); ...

Locate the subsequent elements in an array using Angular 2

In my Angular 2 application, I am working with an array of objects. My goal is to retrieve the next five elements in the array that have a key greater than the one provided. If I input key = 1, the expected output should be values with keys [2, 3, 4, 5, ...

What is the process for activating the Bootstrap modal-backdrop?

While I'm in the midst of some ajax operations, I thought it would be nice to display an overlay on my screen. I could create my own overlay div without any trouble, but considering that I am already utilizing Bootstrap, I might as well take advantage ...

Setting up a variable that has been previously declared outside of the jQuery $.getJSON callback function

When my script executes an Ajax request using jQuery, the data it receives is json_encoded by a server-side script written in PHP. This JSON data is then stringified and parsed with jQuery to create a recordCollection. Each item in the recordCollection is ...

javascript execute a function when a click event occurs

I came across this code online that successfully creates a button document.write(nomedispositivo) var r=$('<input/>').attr({//beginning of button type: "button", id: "field" , value: "Turn On", However, when I add the line: on ...

An error occurred: an unexpected identifier was found when trying to import axios using './lib/axios.js' and require('axios')

I am currently working with a js file: test.js: const axios = require('axios'); console.log('test'); To set up the dependencies, I ran the command npm install This is how my folder structure is organized: test node_modules packa ...

Encountering an endless loop during angular directive compilation

I am facing an issue with a directive that contains dynamic text. My goal is to be able to include ng-click directives in order to trigger functions from the text. I have learned that the recommended approach to achieve this is by compiling the HTML into ...

Find and filter the values in the range.getValues() array that correspond to the first element in apps script

In the spreadsheet provided, I have compiled a list of cities in different states of my country. This information will be utilized in a form; however, it is not feasible for users to sift through an extensive list of all cities listed. Therefore, I am look ...

Converting an AngularJS string variable into an HTML element with sanitization

This is an example of AngularJS code: $scope.checking="<div style="color:red;">check</div>"; Here is the corresponding HTML code: <p ng-bind-html="checking"></p> I utilized $sanitize and the ng-bind-html directive to achieve the ...

Is there a way to update a variable in a controller using AJAX?

Is it possible to update a variable in the controller using Ajax? Controller: $basl = array(2018,11,18,0,0); $deger = 3; $baslamatarihi=Carbon::create($basl[0],$basl[1],$basl[2],$basl[3],$basl[4]); $bitistarihi = Carbon::create($basl[0],$basl[1],$basl[2] ...

What is the best way to make a select tag read-only before the Ajax request is successful

Is there a way to make a select tag read-only before an Ajax success? I tried using this code, but it didn't work: $("#tower").prop('readonly', true); Then I tried this alternative, but I couldn't get the value from the select tag: ...

Learn how to showcase the URL path of an image stored in MongoDB on the front end of a website with the help of Node

I've managed to save the image paths of the uploaded pictures. They are stored like this http://localhost/public/Images/okro.jpg. However, I'm unsure how to retrieve them from the database and showcase them on the frontend. Is there a method to ...

Dividing 2 events for 2 children within a parent element using HTML DOM

Trying to implement select and delete functions, but encountering an issue where clicking on select triggers the delete function and results in a NaN value. Any suggestions for fixing this problem? var collect = document.getElementById('col ...

Attempting to store user input in the database

Currently, I am using XAMPP and following a tutorial to set up a website. The webpage allows users to submit their first name and last name, which should then be stored in a database. However, when testing the functionality, I keep encountering this error ...

How can I resolve the issue of <td> being repeatedly displayed five times instead of just twice in PHP?

Can someone assist me with fixing this for loop issue? I am trying to display controls next to each item in the row, but it is showing 5 sets of controls instead of just 2. <tbody> <?php //retrieve list of supplies $numOfRows = 0; $result = my ...

Display content in the View in ASP.NET based on the parameters passed into the ActionResult function

I'm grappling with a theoretical scenario involving rendering a single View with different content based on user input using MVC in the .NET framework. Essentially, I'm looking to have just one page titled "Create Template", but its contents sho ...

Using AngularJS API within a standalone function: Tips and tricks

I'm diving into the world of AngularJS and I want to make an HTTP GET request to a distant server without messing up my current view code. After some research, I discovered a way to execute a function right after the HTML is loaded by using a standalo ...

Excess space at the bottom of the Heatmap chart in Highcharts

I am facing an issue with a heatmap having extra space at the bottom that I cannot seem to remove. Despite trying various solutions from different Stack Overflow threads, such as adjusting chart.marginBottom, chart.spacingBottom, x and yAxis margins, and d ...

How can I display an array of data with a changing name using a FlatList in React Native?

How can I render a list of array data with a dynamic name in a FlatList using React Native? Below is the list of data that I would like to display in the FlatList: const movies = [ { '4W2JJ0CLbvfLJzBUHORVaz6sAGv2': [ { name: ...

Uncertain about the ins and outs of AJAX

I am a complete beginner in web development. Although I have studied JavaScript and HTML through books, my understanding is still limited. I have never worked with AJAX before and find most online examples too complex for me to follow. My goal is to crea ...