Imagine a scenario where there is a div serving as a container for a sidebar on the left and main content on the right.
The goal is to create a collapsible sidebar navigation, allowing users to hide or display the sidebar with the click of a button.
Despite using Bootstrap 4, existing solutions found on the internet for this feature require extensive work. A simpler approach is sought after.
Here is the current code snippet:
<div class="container-fluid">
<div class="row">
<div class="col-3 px-1 bg-dark" id="sticky-sidebar">
<div class="py-2 sticky-top">
<div class="nav flex-column">
<a href="" class="nav-link">Sidebar</a>
<a href="" class="nav-link">Link</a>
<a href="" class="nav-link">Link</a>
<a href="" class="nav-link">Link</a>
<a href="" class="nav-link">Link</a>
<a href="" class="nav-link">Link</a>
</div>
</div>
</div>
<div class="col" id="main">
<h1>Main Area</h1>
<p>Main content.</p>
</div>
</div>
</div>
The div structure is already split into two blocks, as shown in this codeply:
https://i.sstatic.net/bL7Q4.jpg
How can the sidebar within the div be made collapsible?
Appreciate any assistance provided. Thank you.