Issue with displaying links in Bootstrap header and footer on mobile devices

Main Heading

            <div class="col">
                <nav class="navbar navbar-expand-sm bg-dark navbar-dark">
                    <a class="navbar-brand" th:href="@{/}">
                        <img alt="Site Logo" height="50" th:src="@{images/logo8.png}" />
                </a>
                <button class=navbar-toggler type="button" data-toggle="collapse" data-target="#mainNavbar.#search">
                    <span class="navbar-toggler-icon"> </span>
                </button>
                <div class="collatpse navbar-collapse" id="mainNavbar">
                    <ul class="navbar-nav">
                        <!--- dynamic header ends -->   
                        <th:block sec:authorize="!isAuthenticated()">
                        <li class="nav-item">
                            <a class="nav-link" th:href="@{/login}">Login</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" th:href="@{/register}">Register</a>
                        </li>
                        </th:block>
                        <li class="nav-item">
                            <a class="nav-link" th:href="@{/contact}">Contact</a>
                        </li>
                    </ul>
                </div>
            </nav>
            </div>

Footer Section:

            <div class="col">
            <nav class="navbar navbar-expand-sm bg-dark navbar-dark">
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-targer="#main" >
                    <span class="navbar-toggler-icon"> </span>
                </button>
                <div class="collapse navbar-collapse" id="mainFooterNavbar">
                    <ul class="navbar-nav">
                        <th:block th:each="footerMenu : ${footerMenuItems}">
                        <li class="nav-item">
                            <a class="nav-link" th:href="@{'/m/' + ${footerMenu.alias}}">[[${footerMenu.name}]] </a>
                        </li>
                        </th:block>
                        <li class="nav-item">
                            <a class="nav-link" th:href="@{/about}">About us</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" th:href="@{/registerCompany}">Register your Business?</a>
                        </li>
                    </ul>
                </div>
            </nav>
            </div>

Built using Bootstrap 4.

The header and footer links may not be visible on mobile devices, but they are working properly on laptop/desktop screens.

If you refer to the image linked below and observe the highlighted button in the footer section, it might not be functioning correctly which results in the links not being displayed. The links on the header section are visible, but activating the toggle may not work.
https://i.sstatic.net/6mG7a.png

Answer №1

It seems like your data target is configured incorrectly for the header; it is targeting the wrong element.

Take a look at this line:

<button class=navbar-toggler type="button" data-toggle="collapse" data-target="#mainNavbar.#search">
The correct configuration should be:
<button class=navbar-toggler type="button" data-toggle="collapse" data-target="#mainNavbar">
Moreover, there seems to be an issue with the footer as well. You are attempting to toggle an element ID that does not exist.

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

Preventing HTML file bodies from merging with included files in CSS

Through my experimentation, I have discovered that when including one PHP file within another (using php), the bodies of the files essentially merge. I have a CSS file that applies styles to the body of the main file with a class of "main". The same C ...

Utilizing the entire right side of a browser window, the Bootstrap carousel is displayed in full view

Trying to make the bootstrap carousel take up the entire display of the right side of a browser window. To achieve this, the margins of the carousel need to be adjusted so that the image is positioned in the center of the right side with maximum width (5/ ...

Incorporate the content of an HTML file into a Django template by substituting a portion

I am encountering an issue with replacing a portion of a website that was created using Django with different content. The code snippet in question looks like this: <section id='main_page'> <div id="main_div"> <--! inc ...

Incorporate a click function onto the image within the canvas

After creating a canvas and placing an image on it, I realized that I need to include a click event for that image. Below is the code snippet I have written in attempt to achieve this. <canvas id="myCanvas" width="578" height="1000"></canvas> ...

Is there a way to adjust the size of items based on the window size within a flexbox layout?

I have successfully implemented a basic image gallery using flexbox in HTML/CSS. The current setup includes six images on the page, and thanks to flex-wrap, their configuration changes from 1x6 to 2x3 to 3x2 to 4+2 to 5+1 to 6x1 depending on the window siz ...

Ways to apply distinct styles to various ids and common classes

When dealing with multiple IDs such as id1, id2, and id3 that share common classes like .selectize-input and .select-dropdown, it can become cumbersome to set styles individually for each ID. Instead of writing: #id1 .selectize-input, #id2 .selectize-inp ...

Relative Links from the Server's Root

After exporting HTML files from Next.js, I noticed that all the HREFs are relative to the root of the web server (href="/static/..."). However, when deploying the application to a directory under the web server's root (http://server/app), the links be ...

How can I postpone the spring animation until the image is fully loaded?

Currently, I am utilizing the react-spring library along with the render-props API to adjust the background-size CSS property based on changes in the background image. However, I have noticed that there are instances where the background image fails to loa ...

The rectangular shape extending beyond the boundaries of the canvas

I'm currently working on creating a rectangle within a canvas element. I've set the width of the div to match the width of the rectangle, but unfortunately, the rectangle is extending beyond the left side of the canvas container. My goal is to co ...

Blockage preventing text entry in a textarea

To enhance the basic formatting capabilities of a textarea, I implemented a solution where a div overlay with the same monospace font and position is used. This approach allows for displaying the text in the div with different colors and boldness. However ...

jQuery Auto-Refresh for Dynamic News Feed

Is there a way to have a news feed that updates automatically and in real-time? I am looking to have text appear in a timeline for my visitors as soon as I write it. For instance: ...

Securing HTML pages with ASP.NET MVC authentication

Within my MVC application, there are a few static (pure html) pages that require authentication to prevent unauthorized access. Is there a method to achieve this without transferring all the code to asp files and incorporating a controller, which would t ...

modify the designation of a particular element's group

My goal is to create a webpage that features multiple tables with data. To prevent the page from getting too long, I want users to have the ability to collapse these tables by clicking on the header. I intend to use a + icon to signify expandable content a ...

What are the reasons behind my decision not to utilize the correct Card component in React Bootstrap?

I am new to using react. I am attempting to utilize the Card component from bootstrap in the following way: import React from "react"; import { Card, Button } from "@material-ui/core"; const PortfolioSection: React.FC = () => { r ...

Updating the database with PHP and MYSQL to display a zero value in a specific field

I am facing a problem with updating a specific row in the database. The update process seems to be working, but there is an issue with one of the fields not updating properly. When checking the database after updating, it shows as 0, and I cannot pinpoint ...

Allow users to manually resize <td>'s within a platform

Looking for a way to allow users to manually resize a textarea and iframe in a system I am developing. Here's an example of what I mean: <body> <table width="100%"> <tr> <!-- I want the user to be able to re ...

Responsive design issues with Bootstrap Popover

Whenever I open the popover for the first time, the image is not displayed correctly. How can I ensure that it always shows correctly? Here is a link to the issue: https://jsfiddle.net/n2Lfro30/1/ Below is the button code causing the problem: <button ...

CSS selector for the 'second next' element, checkboxes and labels within MVC forms

I found a helpful resource that explains how to style checkboxes using CSS. It suggests using the + selector to target the label immediately following the checkbox: input[type="checkbox"]{} input[type="checkbox"] + label {} However, I encountered an issu ...

Discovering a sophisticated way to locate a span element using the not(p) selector in Selenium

Within a span element with an ID, there is a mixture of text and a paragraph tag. The goal is to use selenium webdriver to pinpoint the street address in the mix below: <span id="myspan"> <p>fullname</p> street address - has no ...

My goal is to retrieve specific text from an HTML page that contains two distinct classes

I am trying to pull shipping fees from different types of html pages. Each page requires a unique Xpath for extracting the shipping fees. For one type of page, the Xpath is //*[@class="flex flex-row justify-between f6 mid-gray pt2"]//div[2]/text ...