Tips for displaying the Navigation bar on a Mobile device

After creating a Navigation bar using HTML and PHP, I encountered an issue. The Navigation bar appears on desktops and laptops but is not visible on mobile screens.

Here is an example of my code:

<header class="page__header media__img ratio--small">
        <?php include "navigation.php"; ?>

        <div class="nav--sub visible-sm">
            <input type="hidden" name="product_category_id" id="product_category_id" value="<?php echo $_GET["id"]; ?>">
            <ul>
                <?php
                $selectcategory = mysqli_query($conn, "select * from product_category where is_active='1' and is_delete='0'");

                while ($rowcategory = mysqli_fetch_array($selectcategory)) {

                    ?>
                    <li class="<?php if ($_GET['id'] == $rowcategory['product_category_id']) {
                        echo 'selected';
                    } ?>">
                        <a href="product_list.php?id=<?php echo $rowcategory['product_category_id']; ?>"><?php echo $rowcategory['product_category_name']; ?></a>
                    </li>
                    <?php

                }


                ?>

            </ul>
        </div>
     </header>

The code works perfectly on larger screens but has issues on Mobile devices. Can anyone suggest a Bootstrap solution to make it visible on mobile devices?

Laptop View

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

Mobile View

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

Answer №1

It appears that you have included the bootstrap 4 tag in your question, however, the visible-sm class has already been replaced in bootstrap 4. If this is a custom CSS, please make sure to include it in your question.

You can find more information about the comparison between the old and new classes here.

Consider using visible-xs instead;

<div class="nav--sub visible-xs">
...
</div>

Alternatively, you can use d-block d-sm-none

<div class="nav--sub d-block d-sm-none">
...
</div>

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

Display the elements of a div at a reduced size of 25% from its original dimensions

I'm currently developing a JavaScript-based iOS simulator that allows users to view their created content on an iPhone and iPad. This involves using AJAX to load the content/page into the simulator, but one issue is that the simulator isn't life- ...

Crafty Checkbox Selector [ leveraging jquery ]

I have created some fake checkboxes using elements like <span> after the real checkbox and they are working fine! However, I am having trouble counting the checked checkboxes when a checkbox is clicked. I have tried using methods like: $(".elm:chec ...

Is there a way to achieve a page-turning effect in HTML5

Hello there! I was wondering if it's feasible to create a flipping page effect similar to a book in HTML5. If it is possible, could someone please explain how it can be achieved? Appreciate your assistance ahead of time! ...

How can one address the issue of undefined data within table cells?

I have encountered an issue while reading and displaying an XML file on a webpage using a JavaScript script. The problem arises when the page loads, and the information inside the cells of the table shows as "UNDEFINED". The intended display should include ...

Issue with CSS File not being recognized by React Component

After using the webpack create-react-app with npx, I encountered an issue with my component styling. Despite having a CSS file named header.css in the src directory alongside Header.js, my component does not seem to be styled correctly. Here is how my comp ...

Styling elements based on their index in R Shiny

In my R Shiny app, I am looking to color elements based on their index number (first element blue, second yellow, third red). Here is a reproducible example: library(shiny) ui <- fluidPage( tags$style(".control-label:nth-of-type(1) {background-colo ...

Tips for generating a single CSS file that adapts to various screen sizes without the ability to modify the class names within the library

I am currently learning ReactJs and JavaScript and I have a question on how to optimize this css setup effectively. I am utilizing the react-responsive library to detect screen sizes and determine the best layout for my project. The issue I am facing is ...

Customize DAT.GUI: adjust the width of the text field to accommodate longer text entries

Is there a way to increase the width of a text field using DAT.GUI library in JavaScript? According to this source, you can achieve it by setting the style attribute for the first controller like this: gui.add(params, 'StartingVector').name(&apo ...

Achieve the effect of "background-attachment: fixed" using a div element

I am attempting to replicate a similar effect as seen here, which is accomplished using the CSS property background-attachment:fixed. However, I want to achieve this effect using div elements instead. For instance, could I apply this effect to an h1 tag? ...

The Slick carousel code downloaded from their official website is malfunctioning

I found this code on slick's website, but it's not working for me. Can anyone spot what I might be missing? http://codepen.io/anon/pen/pyEddO <html> <head> <title>My Awesome New Website</title> <link rel="styles ...

What is the best way to change the format from yyyy mm dd h:m:s to dd mm yyyy h:m:s?

The date in the MySQL database is stored in the format of now() function as yyyy mm dd hh mm ss. However, I want it to be displayed in the frontend tool as dd mm yyyy hh mm ss. How can I convert it? <?php $addqry=mysql_query("INSE ...

Implementing CSS Transform for Internet Explorer

Hello, is there a way to make this function in IE ?? I have been looking into IE transformations but it appears that they are not supported.. Is there an alternative method or something else? It works in other browsers like Firefox, Chrome, and Opera. I s ...

Utilizing the not(:last-child) selector effectively within a list structure

I need help targeting all elements except the last one in a ul/li list with CSS. The structure looks like this: <ul class="xxx"> <li> <figure> [different divs / content] </figure> </li> <li> <fig ...

utilizing javascript once form elements are dynamically inserted

While dynamically constructing form elements, I encountered an issue with generating unique IDs when the form is submitted. Everything works fine except for the JavaScript function responsible for populating the year in a dropdown selection. The issue ari ...

"Exploring the Power of Jsoup for Selecting

I'm attempting to extract all the links nested within the div class news column index. Here is a snippet of the HTML structure: https://i.stack.imgur.com/zdFWS.jpg Below is the code I have used, but unfortunately, it's not yielding any results. ...

Choosing a container element with jQuery

On an older website using jquery and nodejs, I am working on some filtering tasks. My goal is to target the b elements that are enclosed within a p tag. Specifically, I only want to select those b elements that do not have any text surrounding them. The T ...

Updating the content of a div with a template by clicking a button: a guide

Back in the day, I was comfortable working with jQuery to manipulate the DOM and hide/show content within a container. Now, I need assistance with AngularJS to achieve a similar functionality of displaying or hiding a template inside a container upon butto ...

What is the mechanism behind the functioning of "3D Meninas" (CSS/Animation)?

Recently stumbled upon a fascinating website called "3D Meninas", showcasing an impressive 3D animation effect. Upon examining the HTML code, I noticed there was no mention of any <script> tags or events, leading me to believe that it operates solely ...

Background image not displaying

My web page has a background image set using this CSS: body, html { background-image: url(Content/Images/bg-lounge-2-l.jpg); background-repeat: repeat; background-attachment: fixed; /*background-position: 0 -390px;*/ } ...

Display an HTML code snippet on the webpage

I'm facing a situation that has been discussed before on this platform. However, I want to present my problem in a different light. I am working with PHP and need to display an HTML string from the database on my webpage. The issue is that the CSS app ...