The Boostrap Navbar-Toggler implementation from the documentation is currently stuck in the active state and refuses to toggle off

I need a navbar toggler that still looks good on mobile devices.

Here is the link to the bootstrap documentation I am referring to: https://getbootstrap.com/docs/4.3/components/navbar/

For example, take a look at their code snippet:

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <a class="navbar-brand" href="#">Navbar</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav">
      <li class="nav-item active">
        <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Features</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Pricing</a>
      </li>
      <li class="nav-item">
        <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
      </li>
    </ul>
  </div>
</nav>

Everything works fine when inspecting their site, but when I implement it on my site, the dropdown menu defaults to open and cannot be turned off. Any assistance would be greatly appreciated.

I also have some issues with dependencies due to my lack of understanding in libraries. Here is my messy attempt to make it work:

<head>
    <meta charset="utf-8">
    <link rel="shortcut icon" href="{{ url_for('static', filename='logo/icon_logo.png') }}">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
    
    <link rel="stylesheet" href="static/css/bootstrap.min.css" />
    <link rel="stylesheet" href="static/css/2bootstrap.min.css" />
    <link rel="stylesheet" media="screen" href="static/css/main.css"> 
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
    <title>Mansura</title>
</head>

*stuff in the body below

<script src="https://unpkg.com/@popperjs/core@2"></script>

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="static/js/bootstrap-js/bootstrap.js"></script>

This attempt feels like throwing things against the wall to see what sticks, unfortunately, it hasn't helped so far.

Thank you

Answer №1

It appears that the script is being used twice in your code. To optimize it, consider removing the duplicate script from the header and placing it only in the body section below.

<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>

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

Tips for arranging three images in a single row

I have 3 payment logos in my footer that I want to center and align in one row. Can someone help me with this? sliki { text-align: justify; } sliki img { display: inline-block; width: 75px; height: 100px; padding: 7px; margin-top: -5px; ...

Error: TweenLite has not been recognized

/justincavery/pen/mPJadb - this is a link to CodePen After copying the code from CodePen and running it, I encountered an error: "Uncaught ReferenceError: TweenLite is not defined". The image only draws once and there is no animation unless I press "F5 ...

Creating grids and dividing them using a combination of CSS, JavaScript, and PHP

I've encountered an interesting challenge while working on a web project and would love some advice on how to tackle it: Within a database, I have a collection of images that I want to display in a grid format. The twist is that higher ranked images ...

Uninstalling an Element Using jQuery

There is a requirement to dynamically insert city names into the input field with the ID citiesList. If the value of the input field is empty and the user clicks on the cancel button, then the input should be deleted. However, upon clicking the edit but ...

I aim to display an image with fixed dimensions, unaffected by varying screen resolutions

When monitor resolutions are altered, images may appear in varying sizes even if they are coded with metric values such as cm or mm. Is there a way to maintain the exact size of images displayed on monitors? ...

Creating a centralized form on the webpage

What steps can I take to modify my code to match the structure shown in the image? At present, my code appears as follows: <form id="form" action="/action_page.php"> Login ID:<br> <input type="text" name="id" id="id"> <br ...

Having trouble with your Bootstrap 4 layout when incorporating forms?

Currently, I am working with Bootstrap 4 on a form and facing an issue. Despite using the grid classes, the form does not display as expected. You can view the output here: I anticipated that the 12 columns would be divided into three sections of 4 column ...

Please enter the time in minutes and seconds only

Currently, I am attempting to determine a way to create an <input type="time"> field that exclusively shows minutes and seconds. Despite my efforts with time pickers, I have been unable to achieve the desired result. Does anyone have any suggestions ...

Using PHP, retrieve the innerHTML value from a post method

I am trying to retrieve the innerHTML value of a label element within a form using post method and display it on another PHP page. So far, I have only been successful with textboxes, like in a login form. Any suggestions on how to achieve this? <div ...

Resizing cell height in an HTML table is not supported by Angular 5

In my angular application, I've implemented a component that represents a basic HTML table. However, I'm facing an issue with reducing the height of cells within the table. It seems like my CSS styling is not affecting the display as desired. He ...

What could be the reason behind the occurrence of an error after deleting certain lines of code

The code below is functioning correctly. obj = { go: function() { alert(this) } } obj.go(); // object (obj.go)(); // object (a = obj.go)(); // window (0 || obj.go)(); // window However, an error arises when I comment out the first two lines. obj ...

When a user clicks on an anchor tag, close the current window, open a new window, and pass the

I have a scenario where I have an anchor tag that triggers the opening of a window on click. In this newly opened window, there is a table with a column containing another anchor tag. Here is what I am trying to achieve: Code for the anchor tag: functio ...

Having a floating left <UL> list with floating right text boxes positioned below the UL list instead of being set next to it

I'm attempting to align an unordered list on the left and a group of textboxes on the right within a div tag. The problem I'm facing is that the text boxes are positioned below the list items instead of being adjacent to them. .PersonLI { flo ...

Exploring the dynamic interaction of variables in OpenLayers and Thymeleaf using Javascript

My SpringBoot app is built using Spring Initializer, JPA, embedded Tomcat, Thymeleaf template engine, and packaged as an executable JAR file. Within my Thymeleaf template, I am retrieving lat and lng variables from the controller. The following code snippe ...

Issue with slideout menu hyperlinks malfunctioning

Currently developing a site at , everything seemed ready for deployment until testing in 320x480 mode on mobile revealed that the links on the slideout menu were not working on any mobile device I tried, regardless of resolution or page. I've tried u ...

Is it possible to show elements from an ngFor loop just once when dealing with a two-dimensional string array in a display?

I have an array of nested strings, and I am attempting to display the contents of each inner array in a table format. My goal is to have the first table show the values from the first index of each inner array and the second table to display the values fro ...

Animate the entrance of mobile content as it slides into view while scrolling

I am currently working on a WordPress theme and facing an issue: When I click the hamburger menu without scrolling down the page, the mobile menu slides in smoothly. However, if I scroll down the page, the mobile menu fails to slide into view (I have to s ...

Delete the current row in the table before adding a new one with jquery

Having a HTML table and performing updates using Ajax. Everything is functioning properly so far. When clicking on the Edit button, the values are displayed in the textboxes correctly. However, when clicking on the Add button, the table is updated accordin ...

Avoiding the repetition of CSS animations during Gatsby page hydration

I am facing an issue in Gatsby where I have an element with an initial CSS animation. It works perfectly when the static site loads, but after hydration, it keeps repeating. Is there a way to prevent this from happening? Below is my styled components code ...

PHP and AJAX successfully retrieving data, but failing to redirect to new page

I am trying to pass a username and password to a PHP page using AJAX, and once the credentials are verified, I want to load the main.html page. Currently, when I submit the form, I receive a response of "true," which displays above the form where an error ...