The navigation bar does not show any items

I recently decided to implement the BEM methodology in my application starting with the navbar. However, I encountered a problem where my nav items are not being displayed properly and the hamburger icon is appearing on the desktop version, which is incorrect.

Below is the code I have written:

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;
    }

The link now works correctly.

Visit this jsfiddle for the Navigation Menu with BEM example: Navigation Menu with Bem

If you notice any issues in my code or have suggestions for improvement, please feel free to provide your feedback as I am still learning. Thank you!

Answer №1

Regarding the BEM-method, I found that using the classes "navbar-collapse", "navbar", "navbar-nav" from Bootstrap originally produces better results.

    .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;
        }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<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>


<nav class="main-nav navbar navbar-expand-md">
  <div class="main-nav__logo">
    <li class="main-nav__link">
      <a>Majeni</a>
    </li>
  </div>
  <button class="main-nav__toggler navbar-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 navbar-collapse" id="navbarNav">
    <ul class="main-nav__list ml-auto navbar-nav">
      <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>

If you are unsure if this solution fits your needs, please let me know so we can explore other options.

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 Bootstrap 4 navigation bar fails to be responsive and remains open despite attempts at styling

Having trouble with my navbar functionality... After applying CSS styling, it loses responsiveness and remains open on smaller screens. Here is the code snippet. HTML: <nav class="navbar navbar-expand-sm navbar-dark bg-dark" id="big-bar"> ...

What could be causing my transform scale to not function properly in Bootstrap?

As a complete beginner, I am currently in the process of learning bootstrap. I have noticed that the animation breaks when I apply it, specifically the scaling part. Interestingly, the animation works perfectly fine without Bootstrap. I am wondering if the ...

Capture audio using a web browser

Currently working on a project to create a platform for recording sounds. I'm aiming to incorporate a meter that measures the volume of the sound. Despite extensive research, I haven't been able to discover an HTML5 solution compatible with all b ...

Utilizing columns within the 'segment' element in Semantic-ui to enhance layout design

I am looking to divide the ui-segment into 3 columns and display the ui-statistics evenly. Below is the code I have used in an attempt to achieve this: <div class="ui container"> <div class="ui segment"> <h3 class="ui header"> ...

Implementing beans within an HTML form action allows for seamless communication between the form and

I am seeking assistance as I am unable to locate any tutorials online for the issue I am facing. How do you go about using a <bean:write....> within a <html:form....> The code I have written is: <html:form action="/restricted/client/so ...

What is the best way to compare two values using ajax simultaneously?

Currently, I am facing an issue where I can compare one dropdown value using AJAX, but I am unable to compare two values within the same AJAX call. To achieve this, I need to either pass two values to the AJAX page URL or pass two IDs to the AJAX function. ...

Arranging my pictures through CSS styling

Upon examining my webpage, I've noticed that the images are not properly aligned. My goal is to have the icons perfectly lined up; however, it seems there's a discrepancy depending on another cell, based on the size of the container where the tim ...

The background color for individual table rows only shows up behind the text

I am facing an issue with highlighting a specific row in a table on a page created by an MVC 3 web application. The problem is that when I set the background-color for the tr tag, it only surrounds the text and not the whitespace between the cells. How c ...

Incorporating an external JavaScript or CSS file into a Java web application at runtime

I am looking to dynamically add an external JavaScript or CSS file in my test.html file. Although I am aware of a trick that involves using jQuery like this: $(”).appendTo(‘head’).attr({ rel: ‘stylesheet’, type: ‘text/css’, href: ‘**ht ...

Getting the submit button to be positioned above the open keyboard in React Native

On one screen, we have two View components within another View. I styled it so that the button is at the bottom. When we click on the input text, the keyboard opens up and the screen adjusts to show the input text properly. However, the submit button rem ...

There is a gap found in the span element in Angular, but this gap is not seen in

Comparing two component templates, one in AngularJS and the other in modern Angular: <span ng-repeat="status in statusInformation.statusList | filter : whereFilter" class="show-on-hover"> <span class="app-icon ap ...

Is the image too tiny for the parallax effect?

It seems like the image at the bottom of the parallax theme is showing some spacing at full height. I initially thought the image was too small, but upon comparing it to the one in the top widget area, its height is actually larger. Should I look for a big ...

Having trouble switching tabs on Bootstrap 4.3 beyond the first tab?

I have integrated bootstrap tabs into my web app by following the documentation provided on the bootstrap website. While I have successfully achieved the fade animation for the first tab, I am facing issues with getting the other two tabs to function prop ...

When the text exceeds its container, the CSS property overflow will display only the

.example{ overflow:auto; } <div class="example"> <p>Some Additional Text Here<P> </div> This particular code snippet showcases the initial portion of the text, allowing for scrolling down to reveal items 5 and 6: 1 2 ...

Encountering a JavaScript error due to an erroneous character when trying to parse

I need to convert a `json` string into an object format that is extracted from a `.js` file. Here is the `JSON` string located in `document.js`: [ { "type": "TableShape", "id": "63c0f27a-716e-804c-6873-cd99b945b63f", "x": 80, ...

Electron does not prioritize the @css prefers-color-scheme option

I recently completed an Electron project and decided to incorporate dark mode support into it. However, for some reason, the dark mode feature is not functioning properly. Below you will find the dark.css styling that I have included in every page: @medi ...

When adjusting the browser size, I must minimize the spacing between the headings

I have tried the following code, but when I resize the browser, the space between the two headings for the tab view doesn't work as expected. I want the texts to be displayed without any space when I resize the browser. Below is the HTML and CSS code ...

How can you display a message if a variable is not found in a MySQL table?

My current code is set up to display links from a MySQL database where the movie_id matches the GET id. However, I would like to update it so that if no links are found with that movie_id, it will instead echo a message saying "No links were found." < ...

"Bootstrap classes are not included in the initial setup of a .Net Core Web App

Currently, I am in the process of learning about .Net core web apps by following some tutorials. However, I encountered a problem when attempting to use glyphicons. Despite my efforts, they failed to work and an intellisense warning for "Unknown CSS Class ...

Can both underscores and hyphens be used together in CSS ID naming conventions?

Recently, I proposed to my team the idea of using dashes (hyphens) for our class names and underscores for our IDs. For IDs, I suggested following a naming convention where the element tag is separated from the rest of the ID name by an underscore, resul ...