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>