I am seeking assistance with refining my responsive side menu code

I've been diligently working on my project for about a week now, but I've encountered a small yet incredibly frustrating issue that has me stumped. The problem lies in the functionality of the responsive sidemenu with multiple dropdowns that I have created. Ideally, these dropdowns should open like columns; however, upon opening them for the first time, they initially expand horizontally before stacking on top of each other. Despite my efforts to rectify this by adjusting the width of the columns, I have had no success so far. It's worth noting that I am utilizing Bootstrap 5 for the entire structural build.

<div class="col-auto">
          <div class="container-fluid" style="padding: 0">
            <div class="row" style="margin-right: 0">
              <div class="d-flex flex-column justify-content-between bg-body-tertiary col-auto min-vh-100" style="padding-right: 0">
                <div class="mt-4">
                  <!-- düzeltilecek alan başlangıç -->
                  <ul class="nav nav-pills flex-column mt-2 mt-sm-0" id="menu">
                    <li class="nav-item my-sm-1 my-2">
                      <a class="nav-link text-center text-sm-start" href="#menu1" data-bs-toggle="collapse" aria-expanded="false">
                        <i class="fa fa-square-plus"></i>
                        <span class="ms-2 d-none d-sm-inline">Ana Menü</span>
                      </a>
                      <ul class="nav collapse ms-1 flex-column" id="menu1" data-bs-parent="#menu">
                        <li class="nav-item">
                          <a href="" class="nav-link" aria-current="page">Öge 1</a>
                        </li>
                        <li class="nav-item">
                          <a href="" class="nav-link" aria-current="page">Öge 2</a>
                        </li>
                      </ul>
                    </li>
                    <li class="nav-item my-sm-1 my-2">
                      <a class="nav-link text-center text-sm-start" href="#menu2" data-bs-toggle="collapse">
                        <i class="fa fa-gear"></i>
                        <span class="ms-2 d-none d-sm-inline">Seçenek-1</span>
                      </a>
                      <ul class="nav collapse ms-1 flex-column" id="menu2" data-bs-parent="#menu">
                        <li class="nav-item">
                          <a href="" class="nav-link" aria-current="page">Öge 1</a>
                        </li>
                        <li class="nav-item">
                          <a href="" class="nav-link" aria-current="page">Öge 2</a>
                        </li>
                      </ul>
                    </li>
                    <li class="nav-item my-sm-1 my-2">
                      <a class="nav-link text-center text-sm-start" href="#menu3" data-bs-toggle="collapse">
                        <i class="fa fa-gear"></i>
                        <span class="ms-2 d-none d-sm-inline">Seçenek-2</span>
                      </a>
                      <ul class="nav collapse ms-1 flex-column" id="menu3" data-bs-parent="#menu">
                        <li class="nav-item">
                          <a href="" class="nav-link" aria-current="page">Öge 1</a>
                        </li>
                        <li class="nav-item">
                          <a href="" class="nav-link" aria-current="page">>Öge 2</a>
                        </li>
                      </ul>
                    </li>
                    <li class="nav-item my-sm-1 my-2">
                      <a class="nav-link text-center text-sm-start" href="#menu4" data-bs-toggle="collapse">
                        <i class="fa fa-gear"~></i>
                        <span class="ms-2 d-none d-sm-inline">Seçenek-3</span>"
                      </a>
                      <ul "class="nav collapse ms-1 flex-column">
                        <li class="nav-item">
                          <a href="" class="nav-link">Öge 1</a>
                        </li>
                        <li class="nav-item">
                          <a href="" class="nav-link"">Öge 2</a>";                            
                        </li>
                      </ul>
                      <!-- düzeltilecek alan bitiş -->
                    </li>
                  </ul>
                </div>
              </div>
            </div>
          </div>
        </div>

Answer №1

To ensure correct layout, simply add .navbar-collapse to the sub-navigation. For reference, you can check out this example: https://getbootstrap.com/docs/5.2/components/navbar/#nav

<ul class="navbar-collapse collapse ms-1 flex-column" id="menu1" data-bs-parent="#menu">
  <li class="nav">
    <a href="" class="nav-link" aria-current="page">Item 1</a>
  </li>
  <li class="nav">
    <a href="" class="nav-link" aria-current="page">Item 2</a>
  </li>
</ul>

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

Dynamically add Select2 with a specific class name: tips and tricks

I need help adding a new row with a select2 instance using a class name. The new row is created with the select dropdown, but I am unable to click on it for some reason. var maxGroup = 10; //add more fields group $(".addMor ...

The link and source attributes are missing from the .ejs template

I am experiencing an issue where the href and src attributes in my .ejs file are not referencing my local files properly. My setup involves node.js and express. Here is a snippet from the .ejs template that is causing the problem. <head> & ...

Have the quotes within my markup been replaced with HTML entities?

Currently, I am working on a content page that uses a master page which includes a text box and a button. My goal is to have the button execute some JavaScript code before performing any other actions. At the moment, I am in the testing phase of this JavaS ...

How can you make an object float above an image using CSS?

Is CSS capable of positioning an object over an image? I am trying to overlay a form on top of an image that is not a background. Floating the form doesn't achieve the desired effect, so I'm wondering if there is another way to accomplish this. ...

Div scrolling allows for parallel viewing of PDFs in a side by side arrangement

I have two scrollable elements on my webpage: one positioned on the left side and the other on the right side. The left element is a regular div, while the right element is an object containing an embedded PDF. <object width="100%" height=&quo ...

Styling each list item individually, without interdependence

I am working on a ul that contains several list items comprised of h3s and lis with the "close" class. When I hover, I want to expand the letter spacing on the h3s, but the items with the close class also expand. I have tried using nth child selectors in ...

After making an Ajax call using AngularJS in a PHP file, I expected to receive only a success or fail message. Instead, I received the entire HTML page code along

After making an Ajax call using AngularJS in a PHP file, I expected to receive only a success/fail message. However, I ended up receiving the full HTML page code along with tags. Here is my AngularJS code: $http.post('ajax_Location.php',{ &apos ...

Is there a reason why Social Bar isn't appearing at the top?

My challenge is to position the bar close to the black footer. It appears correctly in Chrome, but not in Firefox and Opera. The screenshot shows how it looks in Chrome. However, in Firefox and Opera, the social bar is positioned lower and does not align ...

Hide the border below the active tab

Could anyone assist me in removing the border below the selected tab? I've attempted multiple approaches without success. I experimented with adding a negative margin to the tab and creating a white border, but as the border I want to conceal is from ...

The grid elements are not in perfect alignment

I'm having trouble aligning the <p> element to the left and the image to the right. The image is not aligning properly with the fourth column, so I need to figure out how to fix that. .content{ display: grid; grid-template-columns: 25% 25 ...

Changing the size of a div using jQuery

I'm attempting to adjust the size of a div element. You can view my progress in this code fiddle: https://jsfiddle.net/bj3m24ks/31/ Kindly refrain from sharing links to other tutorials as I have already explored them all. I attempted to utilize the $ ...

When it comes to using brackets and HTML, I keep receiving an error message indicating that there is no index file

I'm having trouble with this code - it works fine in Code Academy, but I am new to HTML and trying to practice outside of the platform. Every time I try to live preview in Brackets, I get an error message saying "make sure there is an html file or tha ...

Tips for repositioning my sidebar using CSS and HTML

I'm a beginner in CSS and HTML and I'm struggling to make my sidebar move to the side on my website. I have divided my site into three div areas: one for the 'sidebar', one for the 'main content', and one for both called &apos ...

Attempting to isolate just a fragment of the inner content

Option Explicit Sub VBAWebscraping2() Dim IEObject As Object Set IEObject = New InternetExplorer IEObject.Visible = True IEObject.navigate url:="https://streeteasy.com/building/" & Cells(2, 4).Value ...

Using a URL in the fill property is a simple process that involves specifying

Here is the snippet of the code I'm working with: <?xml version="1.0" standalone="no"?> <html> <head> <style> .someClass { fill:"url(#Pattern)"; } </style> ...

An error has occurred in the Shadow Dom due to the inability to access the property 'style' of an

While working on a component using shadow DOM, I encountered the following error in the console: "Cannot read property 'style' of undefined". This issue seems to be related to my HTML code in PHP. The main challenge I am facing is figuring out ho ...

Image renders only on a single page in Express.js

I am facing an issue while attempting to display an image on multiple pages using Pug and Express. The image should be visible on the routes '/', 'data', and 'update'. While it is successfully displayed on the root '/&ap ...

Issues arise when incorporating background images with bootstrap 3

Currently working on designing a responsive layout for an online clothing store using Bootstrap 3. One of the requirements is to use background images inline styles for product containers. However, facing difficulty styling the containers and images to ach ...

Utilizing Dynamic URLs and Transmitting Non-User Input Data from HTML to Python via Flask

After doing some research, I discovered that data can only be sent from input forms in HTML to Python using the POST method. I am now trying to find a way to pass a value (originally stored in a dictionary passed from Python) from HTML to Python. I have t ...

An issue occurred while attempting to hover over the text in the SVG map

I have a United States map. This code contains CSS for styling the map with different colors for each state. It also includes an SVG image of the map and text labels for each state name. However, there is an issue with the hover effect on the state name ...