Dynamic layout problem with navigation pills

I currently have 2 navigation pill buttons designed to alter the layout upon being clicked. Both layouts always include the sidebar which remains constant throughout.

Clicking on Nav pill 1 will display the layout as follows:
sidebar | column 1 | column 2

When Nav pill 2 is clicked, the layout will change to:
sidebar | col 1 | column 2 | col 3

However, I am encountering an issue where one column is displayed next to the sidebar, while the others are appearing below it. I'm puzzled as to why this is happening.

#sidebar {
    /* width: 250px; */
    min-height: 100vh;
    max-height: 100vh;
}

#sidebar_sub_header a {
    border-radius: 0;
}
...
...

This is being implemented using bootstrap 5.3.0 alpha-1

Answer №1

To ensure Bootstrap tabs function correctly, each tab-pane must be enclosed in a tab-content container.

For creating columns, apply the class container-fluid to every tab-pane, then insert a row containing your columns. In the example provided, all columns have equal width, but this can be easily adjusted.

If you desire a full-page layout, add the following CSS:

#sidebar,
main {
  height: 100vh;
  max-height: 100vh;
}

Then assign the class h-100 to each container-fluid in <main>, which sets the height to 100%.

Additionally, give each row the class h-100 and apply the flex class align-items-stretch to ensure each column stretches to the full available height.

Note: This code snippet is based on my response to your previous query, and not on the code presented in your question.

#sidebar,
main {
  height: 100vh;
  max-height: 100vh;
}

.tab-pane .row .col {
  background: tomato;
}

.tab-pane .row .col:nth-child(2) {
  background: lightyellow;
}
<html>

<head>
  <link href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8ad8d5d5cec9cec8dbcacfee75c8d5c8d6cbee83cee3cbccd98a8b8a8b8b8bdcdea9be9faeabf4e0f"><span class="__cf_email__" data-cfemail="681a17170c0b0c0a19180d1c371611"><a href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous"></a></span></a>/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
</head>

<body>
  <div class="container-fluid px-0">
    <div class="row gx-0">
      <div class="col-4 d-flex flex-column gap-1 bg-dark text-white" id="sidebar">
        <div class="p-2">
          <h5>
            Sidebar header
          </h5>
        </div>
        <nav class="">
          <ul class="nav nav-pills flex-column text-center" role="tablist" aria-orientation="vertical">
            <li class="nav-link rounded-0 active" data-bs-toggle="tab" data-bs-target="#tab-1" type="button" role="tab" aria-controls="tab-1" aria-selected="true">Tab #1 - 2 Columns</li>
            <li class="nav-link rounded-0" data-bs-toggle="tab" data-bs-target="#tab-2" type="button" role="tab" aria-controls="tab-2" aria-selected="false">Tab #2 - 3 Columns</li>
          </ul>
        </nav>
        <div class="flex-grow-1 overflow-auto">
          sidebar scroll
          <br><br><br><br><br><br><br><br><br><br><br><br><br>
          end sidebar scroll
        </div>
        <div>
          Sidebar footer
        </div>
      </div>
      <main class="col tab-content overflow-auto">
        <div class="container-fluid h-100 tab-pane fade active show" id="tab-1" role="tabpanel" aria-labelledby="tab-1" tabindex="0">
          <div class="row h-100 align-items-stretch">
            <div class="col">
              Col 1
            </div>
            <div class="col">
              Col 2
            </div>
          </div>
        </div>
        <div class="container-fluid h-100 tab-pane fade" id="tab-2" role="tabpanel" aria-labelledby="tab-2" tabindex="0">
          <div class="row h-100 align-items-stretch">
            <div class="col">
              Col 1
            </div>
            <div class="col">
              Col 2
            </div>
            <div class="col">
              Col 3
            </div>
          </div>
        </div>
      </main>
    </div>
  </div>
</body>

</html>

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

Choosing the name of an HTML element tag using Selenium with Python

Struggling with writing a Python3 function using Selenium to click a link matching specific text. The HTML code is: <a class="name-link" href="/colors/thisOne" </a> Yellow I know how to select the class name "find_element_by_class_name("name-li ...

"Enhancing the aesthetics: Stylish blue borders around Bootstrap

After successfully setting up bootstrap-select, I have noticed that blue borders are showing in two specific instances: 1) within the dropdown menu 2) when a new value is selected I have made some adjustments but the issue persists. Can someone please p ...

Why are the indicators and controls for Twitter-Bootstrap 5 carousel not functioning properly?

Currently, I am working on developing an ecommerce website using the Django framework. However, I am facing challenges with making my bootstrap carousel function properly. When trying to interact with the indicators and controls, nothing happens as expect ...

Divide a SINGLE BACKGROUND IMAGE in HTML into two separate links of equal size, one at the top and

As a beginner in HTML, I am trying to find a way to divide a background image into two equal sections without using image mapping. I attempted to split the links by setting the style to 0% and 50% to designate the top and bottom halves, but unfortunately, ...

What causes the flex div to inherit the full width of its parent div?

I'm having trouble understanding why a flex div always occupies 100% width of its parent element. Consider the code snippet below: #wrapper { width: 100%; height: 100px; background: green; } #flex { color: white; display: flex; ...

Altering pointer during drag操作

Is it feasible to customize the cursor during a drag operation? I've been exploring ways to achieve this for some time now. My goal is to replace the default 'not-allowed' cursor that appears when dragging an object with a different cursor. ...

Make sure to pause and wait for a click before diverting your

Having an issue with a search dropdown that displays suggestions when the search input is focused. The problem arises when the dropdown closes as soon as the input loses focus, which is the desired functionality. However, clicking on any suggestion causes ...

Incorporating mootools scripts into a gwt application

My issue involves creating an animation on a Composite that should start when data is loading. To test this, I created animations on regular divs using HTML: <div class="LoadDataWidget"> <div id="arrow" class="greenArrow"></div> < ...

How can I make a CSS transition activate only on width increases, not decreases?

My element's width changes under different conditions, and I've implemented CSS with a transition for the width: .element-class { transition: width 500ms ease 0ms; } However, I only want the transition to occur when the width is decreasing. ...

Navigate through each element with a specific class name in a block of HTML code using

Currently, I am dealing with an HTML string that is being retrieved through AJAX. Let's assume it looks like this: var htmlString = '<div class="post"></div><div class="post"></div>'; I want to find a way to iterat ...

What could be causing my Node.js website to have trouble locating pages in the public directory?

Embarking on my journey in web development using node.js, I encountered an issue while trying to load a particular page, which led to the following error message in my browser: Cannot GET /public/pages/terms-and-conditions.html The file structure is orga ...

Create a div that can grow in size without the need to set a specific height for it

Here is an example of my HTML code: <div id="wrapper" class='common'> <div id="left" class='common'>Menu I Menu II Menu III Menu IV</div> <div id="right" class='common'>hello world..hello world ...

Personalized AWS Cognito: Strategies for Tailoring Input Field Designs

MY CURRENT CHALLENGE: Within my Vue application, I am utilizing the AWS authenticator for managing login and signup processes. However, customizing its style has proven to be difficult due to the structure being built with shadow DOM elements. https://i. ...

The Perfect Scrollbar feature is not functioning properly in conjunction with the accordion menu

I am having some trouble with implementing the Perfect Scrollbar alongside an accordion slider menu. The scrollbar is not working as expected, and you can view the fiddle here. On initial page load, the scrollbar only appears for the first sub-menu aft ...

What are the benefits of using CSS to convert text to uppercase?

Today, I came across an intriguing observation. While browsing through code, I noticed that text was being transformed to uppercase using CSS instead of the common JavaScript method toUpperCase(). Surprisingly, this approach caused a test to fail. The test ...

"Optimizing the alignment of logo and toggle bar items in Bootstrap 5 navbar for

Currently, I am working on customizing an 11ty+bootstrap template that I cloned from Github. The template can be found at this link and I am making the changes on my localhost. The navbar in the template has a text logo with background color, margins, and ...

Adding space between the cells on the far left and far right of the table and the border

I need some advice on creating a table in HTML where the borders of the leftmost and right most cells do not extend all the way to the edges of the table. Here's an example: | ____ | In this example, the top border of the cells is continuous within ...

implementing HtmlSpanner with an appended css stylesheet

Using HtmlSpanner with CSS for TextView I recently discovered a library called HtmlSpanner that claims to assist in adding an HTML string with CSS to a TextView. However, I am struggling to locate any detailed documentation on how to achieve this, except ...

Include content within the navigation bar of Bootstrap 3.3

I am trying to insert text at the end of the header in a jumbotron template: <div id="navbar" class="navbar-collapse collapse"> <form class="navbar-form navbar-right"> <div class="form-group"> <input type="text ...

Issue arises when applying both overflow-x:scroll and justify-content:center

Encountering a problem with using overflow-x: scroll and justify-content: center on a flex parent container. Here is my code snippet: The issue: the first flex child item is not visible as it is cropped on the left side. Please refer to the screenshot and ...