I am currently using Bootstrap 5.3 and having difficulty collapsing this sidebar behind a hamburger menu on smaller screens. I have tried various solutions with the existing classes and utilities, but they are primarily designed for horizontal navbars. This causes some issues when applied to my vertical sidebar layout, leading to unexpected behavior.
<html><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="84e6ebebf0f7f0f6e5f4c4b1aab7aab6">[email protected]</a>/dist/css/bootstrap.min.css">
</head>
<body>
<div class="container py-2">
<div id="app">
<nav class="navbar navbar-expand-md navbar-light shadow-sm p-0" id="topnav">
<div class="container">
<h1 class="m-0 text-uppercase">
<a class="navbar-brand" href="#">
Hello World
</a>
</h1>
</div>
</nav>
<main class="container py-4">
<div class="row">
<div class="col-md-2 py-md-1 px-md-0 me-md-2 bg-body shadow border-1">
<div class="row p-3 d-none d-md-flex">
<div class="col mr align-self-center">
Notice
</div>
</div>
<nav class="nav flex-column nav-pills" id="leftnav">
<a class="nav-link d-flex" href="#">Menu 1</a>
<a class="nav-link d-flex" href="#">Menu 2</a>
<a class="nav-link d-flex active" href="#">Menu 3</a>
<a class="nav-link d-flex" href="#">Menu 4</a>
<a class="nav-link d-flex" href="#">Menu 5</a>
</nav>
</div>
<div class="col-md-9 py-md-1 ms-md-2 bg-body justify-content-center shadow-sm">
Here's where the content goes.
</div>
</div>
</main>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dfbdb0b0abacabadbeaf9feaf1ecf1ed">[email protected]</a>/dist/js/bootstrap.bundle.min.js"></script>
</body></html>
This particular HTML structure was originally created for Bootstrap 3 or 4 and has been adapted over time to work with more recent versions of Bootstrap. I am open to reconsidering the entire layout (even switching to a standard horizontal navbar) to simplify things. I prefer not to duplicate the sidebar, as suggested in some outdated articles discussing collapsing sidebars.