The Bootstrap menu vanishes when tapped on mobile devices, and the header image fails to resize accordingly

After spending several hours attempting to troubleshoot on my own and seeking assistance from other online resources, I have been unsuccessful in resolving two key issues with my website.

The first problem lies with the bootstrap navigation menu on www.discoverbugs.org. While it appears correctly on desktop, the drop-down menu disappears when clicked on mobile. What is causing this issue and how can it be rectified?

Additionally, the header image extends across the entire width of mobile screens, creating a visually unpleasing display. Despite my efforts to set maximum and minimum widths, the images continue to present incorrectly. Could someone please assist me in editing this aspect as it currently looks quite absurd?

CSS:

@media screen and (max-width: 420px) { 
    header {
        padding: 65px 0 0px;  
    } 
}

Index.php


    <header class="bg-primary text-white">
      <div class="container text-center">
        <img src="img/header-v6.jpg">
      </div>
    </header>

Header.php (Navigation menu)

<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top" id="mainNav">
  <div class="container">
    <a class="navbar-brand js-scroll-trigger" href="index.php">Discover Bugs</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarResponsive">
      <ul class="navbar-nav ml-auto">
        <li class="nav-item">
          <a class="nav-link js-scroll-trigger" href="index.php">Home</a>
        </li>
         <!-- Additional Menu Items -->
      </ul>
    </div>
  </div>
</nav>

Javascript coding:

<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>

Answer №1

The reason why Bootstrap 3 JavaScript is not compatible with Bootstrap 4 is quite straightforward.

In essence, to make Bootstrap 4 CSS work effectively, you must also incorporate Bootstrap 4 JavaScript (along with jQuery 3.2.1 and popper.js).

To resolve the header image issue, simply add the img-fluid class to the image tag like this:

<img class="img-fluid" src="img/header-v6.jpg">

This adjustment will ensure that the image behaves responsively.

To address the initial problem, utilize the CSS and JavaScript files provided in the template below (and load them in sequence):

<!doctype html>
<html lang="en>">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  </head>
  <body>

<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top" id="mainNav">
    <div class="container">
        <a class="navbar-brand js-scroll-trigger" href="index.php">Discover Bugs</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <div class="collapse navbar-collapse" id="navbarResponsive">
            <ul class="navbar-nav ml-auto">
                <li class="nav-item">
                    <a class="nav-link js-scroll-trigger" href="index.php">Home</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link js-scroll-trigger" href="testimonials.php">Testimonials</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link js-scroll-trigger" href="collections.php">Collections</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link js-scroll-trigger" href="form.php">Costs & Booking</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link js-scroll-trigger" href="faq.php">FAQ</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link js-scroll-trigger" href="contact.php">Contact</a>
                </li>
            </ul>
        </div>
    </div>
</nav>

<div class="container mt-5 pt-5">
    <div class="row">
        <div class="col">
            <h1>Hello, world!</h1>
        </div>
    </div>
</div>

    <!-- Optional JavaScript -->
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
  </body>
</html>

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

The requirement for my object is to have an array of nested objects. However, instead of adding the inner objects to the array, it mistakenly creates new outer objects

I am struggling to form an array of objects with the given structure obj { name : name, items : [] } In this setup, items should be an array consisting of item objects like so item { itemName : itemName, price : price } However, when I attempt to insert ...

Looking for assistance with getting 2 functions to run onLoad using Ajax - currently only 1 is operational

In the coding journey, I first implemented shuffle functions for arrays which was successful. Then, I proceeded to define two global variables that would dictate the random order in which images are displayed on the webpage. The variable picOrder was meant ...

I need to know how to use Axios to fetch data from multiple sources at the same time without any risk of the

Trying to initiate multiple axios operations simultaneously to fetch data from various sources at once using a loop leads to the received data getting intermingled and corrupted. Even creating distinct axios instances for each data source doesn't see ...

Link clicking event fails to trigger button clicking event on initial attempt in Internet Explorer. However, it works successfully on the second click

I'm feeling frustrated with a situation on my web page. I have a div that opens up in colorbox when clicked. Inside the div, there are links that should trigger an event in the code below. This event is meant to fill a hidden field and then click a se ...

Compel the browser to launch a fresh tab

I'm currently working on an app that involves uploading files. One issue I'm facing is that the file system pop up doesn't close after the upload, causing a quarter of the screen to be covered while the test keeps running in the background. ...

Stylish CSS menu that adjusts to different screen sizes, featuring a centrally aligned h1

I am trying to center an h1 element in my navigation, alongside two other elements, without using an image. I want it to be responsive as well. I have attempted various methods but have had limited success, as most solutions require the use of background i ...

Is there a way to conceal an element using identical markup with jquery?

Having trouble with two custom dropdown lists that share the same markup. Ideally, only one should be visible at a time. However, both are currently opening simultaneously. Additionally, I need them to close when clicking outside of the list. It's ne ...

Overlay Image on Thead Background

I am working on an HTML document with CSS and have a specific requirement. I need to set a background image in the <thead> element, which should act as an overlay for the other tds. Can this be achieved? The desired outcome is to have the image only ...

Is it possible to showcase a notification as a popup or alert in Django?

I'm working on a form in Django that redirects to itself after submission. I want to show a message saying "You have entered (work_area)" as a popup or alert that users can close. However, my current setup only displays the message within the HTML aft ...

Animate the child element of this selector using jQuery

When using the this selector to animate an image within the li and a elements, I encountered a problem. Here is the Jquery code snippet: jQuery(document).ready(function () { jQuery(".jcarousel-skin-tango li").mouseenter(function () { ...

The task was unsuccessful as Travis encountered a status code of 127

I'm currently using Travis for the project build process. My deploy script is as follows: deploy: provider: script script: - npm run deploy - npm run test:deploy-results skip-cleanup: true on: branch: build Below is the npm scrip ...

Is there a way to capture and prevent the onMouseWheel event from being processed in other parts of the code

Is there a way to capture the onMouseWheel event for the entire page? I am working on custom scrolling and need to prevent other elements on the page from handling this event. Any suggestions on how to achieve this? Appreciate your help in advance. ...

Error: The function `map` cannot be applied to this.props.comments

I am new to coding in React and have been trying to create a comment box. However, I keep encountering errors such as TypeError: this.props.comments.map is not a function and Uncaught TypeError: comments.concat is not a function. I am feeling lost and conf ...

Using XPath and Selenium in Java to extract information from HTML tables

I need help organizing data without HTML tags. The data I have looks like this: <table class="SpecTable"> <col width="40%" /> <col width="60%" /> <tr> <td class="LightRowHead">Optical Zoom:</td> ...

Strange state manipulation in React JS using MaterialUI

Having trouble displaying an input component from material-ui, as it crashes the page when I type a few letters. import React from 'react'; import Input from '@material-ui/core/Input'; export default function ComposedTextField() { ...

Error message: Variable in template cannot be replaced by Directive

Whenever I attempt to include parameters in a directive that contains another directive, I encounter an error message displaying This particular error Below is the structure of my directive: app.directive('percentageSquare', function(){ ret ...

Variations in site titles across different pages of the same website

I'm encountering a strange issue. The title of my website appears differently on two separate pages, even though the CSS is identical when inspected. Check out my site: ryantuck.io This is how the title looks across the site: And this is how it ap ...

Display the next dropdown menu after selecting an option from the first dropdown using a JQuery

Looking to dynamically update my second drop-down list from the database based on the selection made in the first drop-down list within a jQuery dialog. ASPX <asp:UpdatePanel ID="upnl" OnLoad="upnl_Load" runat="server" UpdateMode="Conditional"> < ...

The number of articles in the MongoDB database is currently unknown

Currently, I am in the process of developing a blog using nodejs, express, and mongodb with jade as the template engine. The folder structure of my project looks like this: project/ modules/ views/ index.jade app. ...

Creating a Kendo UI grid within a Kendo UI window and utilizing Knockout JS bindings

I'm encountering an unusual issue while working with Kendo UI and Knockout JS libraries. When attempting to display a kendo grid within a kendo window, the rows inside the grid are being duplicated. Below is a snippet of the code I'm using: JS: ...