The orientation of my bootstrap navbar menu is vertical instead of horizontal

I've been struggling with this issue for hours now. Despite searching online for solutions, I haven't been able to make my navbar list go vertical or get the "logout" and "My Posts" options to drop down when "Author" is selected as it should. Here's the HTML snippet causing me trouble:

<nav class="navbar navbar-light bg-faded">
  <div class="container">
    <a href="/" class="navbar-brand">
      Bella<span class="light">blog</span>
    </a>
    <button class="navbar-toggler hidden-sm-up pull-xs-right" type="button" data-toggle="collapse" data-target="#exCollapsingNavbar">
      &#9776;
    </button>
    <ul class="nav navbar-nav pull-sm-right hidden-xs-down">
      <li class="nav-item">
        <%= link_to 'Blog', root_path, class: "nav-link #{yield(:blog_active)}" %>
      </li>
      <li class="nav-item">
        <%= link_to 'About', about_path, class: "nav-link #{yield(:about_active)}" %>
      </li>
      <li class="nav-item">
        <%= link_to 'Contact', contact_path, class: "nav-link #{yield(:contact_active)}" %>
      </li>
      <% if author_signed_in? %>
        <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          Author
        </a>
        <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
          <li>
            <%= link_to 'My Posts', authors_posts_path, class: "dropdown-item #{yield(:author)}" %>
          </li>
        <li>
          <%= link_to 'Logout', destroy_author_session_path, method: :delete, class: "dropdown-item" %>
        </div>
      </li>
      <% end %>
    </ul>
  </div>
</nav>

Below is the SCSS code that accompanies the HTML above:

.navbar {
  border-radius: 0;
  margin-bottom: 20px;
  background-color: gray;
  .navbar-brand {
    font-weight: bolder;
    color: $accent-color;
    .light {
      font-weight: 300;
      color: white;
    }
  }
  .navbar-expand-* {
    outline: none;
  }
  .nav-link {
    color: $light-primary-color !important;
    &.active {
      color: $text-primary-color !important;
    }
  }
}

.collapse-bg {
  padding: 0 !important;
  .card {
    margin-bottom: 0;
    border-radius: 0;
    border: none;
  }
}


.collapse-bg .card .list-group-item {
  padding: 0;
  border-radius: 0 !important;
  border-color: black;
  a {
    background-color: #1a1a1a;
    color: #bdc3c7;
    width: 100%;
    height: 100%;
    padding: 10px;
    &:active {
      color: white;
      border-bottom: none;
    }
  }
}

Despite following an example from https://www.w3schools.com/howto/howto_css_dropdown_navbar.asp, the dropdown feature still isn't working properly in my project.

Answer №1

It might be a good idea to double-check the bootstrap CSS and JS imports in your HTML file.

If you need help, please take a look at Bootstrap's documentation!

Don't forget about Dropdowns, Tooltips, and Popovers for displaying and positioning (Popper.js is required).

Make sure you've correctly imported all necessary files: (bootstrap.min.css, jquery-3.3.1.slim.min.js, popper.min.js, bootstrap.min.js).

For vertical navbar lists, consider using Bootstrap's sidenav instead of the standard navbar.

Here's an example of a sidenav: sidenav example

I hope this helps answer your question! :)

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

Double dragenter events triggered before dragleave in HTML5 drag and drop functionality

Currently, I'm researching HTML5 Drag and Drop functionality by using this resource. However, I've encountered an issue with the dragenter event that seems to fire twice for child elements before the dragleave event. Because of this, the dashed b ...

Prevent the parent from adjusting to fit the child's content

Recently, I've been working on creating a horizontal menu bar and I have condensed the CSS as much as possible. However, I am facing an issue where I do not want the ul li element to adjust its size based on the content of the ul ul. Any suggestions o ...

Using PHP to Dynamically Add Content to HTML with AJAX

Utilizing AJAX for dynamic page functionality poses a challenge when attempting to replace specific content on the HTML page with data retrieved from a MySQL database. Echoing out the information directly will cause an error as the PHP code is executed thr ...

I am attempting to load the ajax content into separate divs simultaneously

When I attempt to load the ajax into two separate divs, I notice that despite calling for data to be placed in two different divs within the ajax code, it all ends up in one div. <script>$(document).ready(function(){ $.ajax({ url: "http: ...

Changing the color of MUI Typography when selected

Struggling to modify the styling of the Typography component nested inside a MenuItem. Unable to apply styles to ListItem as intended Check out my code here: https://codesandbox.io/s/dztbc?file=/demo.tsx:1481-1804 Desired behavior: Change styling on sele ...

Is it feasible to create a full-page text gradient clip without it repeating on each individual element?

.gradient { background-color: #00ccaa; background: linear-gradient(0deg, #00ccaa, #f530a9); background-size: cover; background-clip: text; box-decoration-break:slice; -webkit-background-clip: text; -webkit-text-fill-color: transparent; -web ...

A Python program that creates an HTML webpage

I am currently working on a Python script that, when launched on localhost with Apache, will generate an HTML page. Here is the script (test.py): #!/usr/bin/python # -*- coding: utf-8 -*- import cgitb cgitb.enable() import cgi form = cgi.FieldStorage() ...

Search for every div element and locate the ul element within it. Calculate the total number of table rows present in the ul element. Add this

There is a list on my website with a sublist called .cart-items. This sublist contains a table with multiple rows. My goal is to iterate through each .cart-select item and count the number of tr elements within the cart-items. The count should then be disp ...

Relocate the HTML checkbox to the left side of its width

I need an answer that utilizes only CSS, without any JavaScript. In a form, I have a checkbox as follows: <label for="autologin">Remember Me</label> <input type="checkbox" class="checkbox" id="autologin" name="autologin" value="1"> <d ...

Storing Avatars in Database: ROR/Mysql Design Query

Currently, I am in the process of developing a Ruby on Rails website where users will have the ability to select avatars from a specific set that I will provide, similar to turntable.fm. Depending on the user's rank, they will unlock access to differe ...

The JavaScript-set value in a form field is not being transmitted to the PHP script within the $_POST array

Struggling to pass a JavaScript value to a .php script, and then on to a .txt script. It works fine with regular numbers, but when trying with the variable it fails, leaving the .txt file blank. Despite extensive research online, I can't seem to get i ...

"Despite attempts to use workarounds, inline-block elements still create unnecessary line breaks due to their inherent

My header is behaving unexpectedly when I break a sentence into separate elements. I have attempted all the suggested solutions here: How do I remove the space between inline-block elements?. I even tried applying font-size: 0 to the parent element. The e ...

Utilizing the '::marker' pseudo-element for generating Markdown-inspired headers

This code snippet is functioning correctly, however, I have a suggestion to make it more appropriate. Instead of using '::before', why not try using '::marker'? I attempted this adjustment but encountered an issue. Can anyone explain wh ...

Fixing the issue of list styles not displaying properly when using CSS3 columns in Webkit can be achieved by

example here: http://jsfiddle.net/R7GUZ/3/ I'm struggling to make the list-style property work in webkit for a parent OL that is styled with -webkit-column-count: 2; -moz-column-count: 2; column-count: 2; Is there a way to format an ordered list ...

Maintaining the state of perspectives

I am currently working on an app that utilizes a form to filter objects from a database. Each change in the form triggers a request to the server for filtered objects, which are then displayed in another view. However, I have encountered an issue where the ...

Moving smoothly after animation using @keyframes

I've successfully implemented a loading indicator using CSS3 keyframes, which animates its width from 0% to 100% when the .loading class is added to my loading bar. However, once the loading is complete, I want to smoothly transition out of the keyfra ...

Bootstrap allows for the use of video backgrounds, offering the option for borders to be included

Having trouble with a Bootstrap HTML page featuring a video background? The issue is that sometimes the video has borders on the left and right, and occasionally on mobile devices as well. Oddly enough, when the browser (Chrome or Firefox) is refreshed, th ...

What is the best way to transfer floating point input values from one page to another for later retrieval?

Is there a way to send floating point values to another page? I tried sending a floating point value in an AJAX request, but the receiving page only gets an integer value. <div class="form-group"> <label for="" class="col-sm-4 control-label"> ...

Tips on eliminating the blue color from a hyperlink within a button

Currently, I am in the process of designing an HTML email template. I have included a green button in the template and now need to eliminate the blue color from the hyperlink within the button. I have exhaustively tried different solutions such as using ! ...

Utilize CSS to style Hover effects

Can someone please assist me with this issue? I am having trouble getting the CSS to work for my hover effect. I suspect that there might be a problem with my syntax. Here is the HTML code: <div id="horizontalmenu"> <ul> <li><a h ...