Burger icon appearing on a computer screen

My navigation bar, created using bootstrap 4 and BEM methodology, is displaying the hamburger menu on desktop devices instead of being hidden. Can someone help me identify what's causing this issue?

If you want to take a look at the code, here is the link to the jsfiddle: Bem Navbar menu

HTML

  <nav class="main-nav">
      <div class="main-nav__logo">
        <li class="main-nav__link">
          <a>Majeni</a>
        </li>
      </div>
      <button class="main-nav__toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false"
        aria-label="Toggle navigation">
        <span class="main-nav__icon navbar-toggler-icon"></span>
      </button>
      <div class="main-nav__collapse collapse" id="navbarNav">
        <ul class="main-nav__list ml-auto">
          <li class="main-nav__item--active">
            <a class="main-nav__link" href="#">Home
              <span class="main-nav__current sr-only">(current)</span>
            </a>
          </li>
          <li class="main-nav__item">
            <a class="main-nav__link" href="#">About us</a>
          </li>
          <li class="main-nav__item">
            <a class="main-nav__link" href="#">What we do</a>
          </li>
          <li class="main-nav__item">
            <a class="main-nav__link " href="#">Projects</a>
          </li>
          <li class="main-nav__item">
              <a class="main-nav__link " href="#">Contact</a>
            </li>
        </ul>
      </div>
    </nav>

css

   .main-nav {
        background-color: green;
        position: fixed;
        top: 0;
        left: 0;
        display: flex;
        justify-content: flex-end;
        align-items: stretch;
        height: 50px;
        width: 100%;
        &__item{
                padding: 0 2em;
                background-color: #088887;
                display: flex ;
                align-items: center;
            }
        &__link{
            list-style-type: none;
            list-style: none;
        }

I would appreciate any suggestions or corrections if I am implementing something incorrectly in my code. Thank you!

Answer №1

It appears that you are missing a responsive class to control the visibility of your content on different devices.

If you want the content to be visible only on "xs" screens, you should use the following classes:

.d-block .d-sm-none

Check out the updated JSFiddle to see the changes (You may need to adjust the window size to observe the effect) - https://jsfiddle.net/rjysf257/14/

This information is sourced from the Bootstrap 4 documentation, which emphasizes the importance of using responsive display classes to hide or show elements based on the screen size:

To hide elements, you can utilize the .d-none class or one of the .d-{sm,md,lg,xl}-none classes for specific screen sizes.

If you wish to display an element only on certain screen sizes, you can combine the .d-none class with a .d-*-block class. For example, .d-none .d-md-block will hide the element on all screen sizes except medium devices.

For more details and examples, refer to the Bootstrap 4.0 Utilities: Display (Hiding Elements) documentation.

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 concealing the browser's scroll bar on a designated webpage

Is there a way to hide the browser scrollbar on just one page of a website without affecting other pages? I have only been able to hide the scrollbar using body::-webkit-scrollbar { display: none; } However, this code hides the scrollbar for the enti ...

The CSS styles on my GitHub Pages website are not being reflected on the HTML page

I've been struggling for a while now to host my Portfolio CV on GitHub and I can't seem to get my CSS styles to apply correctly on the URL. - This is how I have linked it in the HTML document: <link rel="stylesheet" type="text/ ...

What is the reason for a newly created custom class to have priority over a class with a different name from an earlier loaded file?

Utilizing Bootstrap 4 from the CDN, I have created a new class named: .pt-10 { padding-top: 10rem !important; } The css files are loaded in the following order within the html document: <link href="bootstrap cdn css..."> <link href="my file"> ...

Angular navigation bar dropdown menu is not displaying properly

Check out this Bootstrap Navbar I recently added the same code to my Angular project, but I'm having trouble getting the dropdown to display properly. Take a look at the Stackblitz Demo I need help with two things: Getting the dropdown to show c ...

What is the best way to access the tooltip text in Reddit?

Currently, I am in the process of developing a Selenium web scraping tool specifically for Reddit. However, I am encountering some challenges in extracting the timestamp displayed in the image. from selenium import webdriver from webdriver_manager.chrome i ...

Bootstrap is an outdated page template that lacks responsiveness

My code below features a page designed using Bootstrap HTML and CSS, but it doesn't look right on all devices. For example, on mobile devices, the grid appears zoomed in and unresponsive. I tried removing grid-template-columns: auto auto;, which fixed ...

Using jQuery Chosen to showcase numerous select fields simultaneously within a webpage

I have implemented a search feature using in a dropdown list for user convenience. On the post/create page, I have added 2 tabs: Link & Text Both tabs include a "subreddit_id" field that utilizes $(selector).chosen();. Interestingly, the jQuery chos ...

Form aligned to the right

Is there a way to align the form to the right in this code? HTML @import url('https://fonts.googleapis.com/css2?family=Noto+Sans:wght@500&display=swap'); * { font-family: "Noto Sans", sans-serif; font-weight: 500; } .no-outline { ...

Utilizing Skeleton to create a cropped text button on an iPhone

I am currently using Skeleton for my simple CSS needs. While it works fine on desktop, I have noticed that on an iPhone, the text in my button gets cropped as shown in the picture. https://i.stack.imgur.com/EYo2P.png Below is the HTML code I'm using ...

What is the best way to show an on/off button in an HTML page when it loads, based on a value stored in a MySQL database?

Is there a way to display a toggle button onload based on a value from a MySQL database table? I need the button to switch between 0 and 1 when clicked. I've looked at several solutions but none of them seem to work for me. Any help would be greatly a ...

Issue with JQuery .click() function not targeting designated elements

I am currently facing a challenge with the freeCodeCamp Simon Game project (JSFiddle). I am unable to figure out why the .click() function is not working as expected, even though I have successfully used it in my previous projects without any issues. Belo ...

The jQuery plugin for mmenu does not activate the selected menu item

I recently implemented a jQuery menu plugin that I found on Overall, everything is functioning correctly. However, I am encountering an issue where the active state is not displayed when selecting a sub menu. Instead, it keeps redirecting to the main page ...

Utilizing the Ternary Operator for conditional rendering in React is causing issues with HTML elements

Why does React display the "signin" div when the user is not true, but displays the children of the "user-profile" div inside the "signin" div when the user is true? I have tried multiple solutions to fix this issue, but it persists. If anyone knows how t ...

The navigation bar text spills over the designated area

I'm facing an issue in the front end where the navbar does not adjust on narrow screens, causing text to overflow. Although it works fine on wide monitors and mobile screens, iPads in portrait view have the last section of the navbar extend outside of ...

How to Implement a Dropdown Menu in HTML and CSS for Navigation Bars

Currently, I am in the process of creating a website at www.bossfakeid.co.uk. I am looking to add a dropdown menu to the "Products" section of the navbar. I found a dropdown menu solution that I would like to implement from this link: http://codepen.io/wil ...

Display or conceal form elements depending on the JSON response

Upon making an api call, a json Response is received with the following structure: {"Field":"Amount","FieldName":"Amount","FieldType":"Numeric","MaximumLength":128,"MinimumLength":0,"Options":"Mandatory"} This api call yields between 5-10 of these object ...

Include a hyperlink in an email using PHP

I am currently using an HTML form textarea along with PHP to send emails through my website. My question is, how can I successfully insert a link into the email message body? I attempted to do it like this: <a href="http://www.xxxxx.com/">Visit the ...

Tips for aligning text vertically within a definition list

I am working on a definition list where I need to vertically center the text within each dd element. dl, dt, dd { margin:0; } dt { background: blue; } dd { min-height: 100px; background: gold; border-bottom: 3px solid white; } <dl ...

Displaying an alert when the text box contains a duplicate value

I have a set of input fields with various values that can be edited but must not be left empty (if left empty, display an alert). When I update a field with a new value, if that new value matches any of the other input field values, I want to display an al ...

Include a search button within the search box of the Custom Search Engine

Can anyone help me with adding a search button to my HTML code? I've tried implementing it, but when I try to search something on a website like YouTube, the results show up without displaying my search query. How can I fix this issue and what changes ...