There are numerous fantastic examples available on w3schools.com showcasing the implementation of a Fixed Sidebar
Below is my take on it using Bootstrap 4
, CSS
, and vanilla Javascript
var sideNavBarWidth = document.getElementsByClassName('side-navbar');
var innerNavBar = document.getElementsByClassName('inner-navbar');
// Creating a 1rem space from both sides
innerNavBar["0"].style.minWidth = (sideNavBarWidth["0"].offsetWidth - (32)) + 'px';
.list-group-item {
cursor: pointer !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid bg-light">
<div class="col-12">
<div class="row">
<div class="col-3 border border-dark px-0 py-4 side-navbar">
<div class="position-fixed inner-navbar mx-3">
<ol class="list-group">
<a href="#" class="list-group-item my-1">Chapter 1</a>
<a href="#" class="list-group-item my-1">Chapter 2</a>
<a href="#" class="list-group-item my-1">Chapter 3</a>
<a href="#" class="list-group-item my-1">Chapter 4</a>
<a href="#" class="list-group-item my-1">Chapter 5</a>
</ol>
</div>
</div>
<div class="col-9 border border-dark px-4 py-4">
<div class="row mb-3 px-4 jumbotron-fluid">
<h1>Chapter 1</h1>
</div>
<div class="row mb-3 px-4 text-justify">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
labore et dolore magna
aliqua. Volutpat ac tincidunt vitae semper quis lectus nulla at volutpat. Interdum varius sit
amet mattis vulputate
enim nulla aliquet. Malesuada fames ac turpis egestas. Blandit aliquam etiam erat velit
scelerisque in dictum. Sit amet
massa vitae tortor condimentum lacinia quis. Non arcu risus quis varius. Eget nulla facilisi
etiam dignissim diam quis.
Quis imperdiet massa tincidunt nunc pulvinar sapien et. Nullam non nisi est sit amet facilisis.
Eget duis at tellus at.
Aenean vel elit scelerisque mauris pellentesque pulvinar pellentesque habitant. Suscipit tellus
mauris a diam maecenas
sed enim. Diam maecenas ultricies mi eget mauris pharetra et ultrices neque. Orci porta non
pulvinar neque laoreet
suspendisse interdum. Sem viverra aliquet eget sit amet tellus cras. Pulvinar pellentesque
habitant morbi tristique
senectus et. Aliquet sagittis id consectetur purus ut faucibus pulvinar.
</div>
<div class="row mb-3 px-4 text-justify">
[Repeat Lorem Ipsum content for demonstration purposes]
</div>
[Repeated sections to showcase functionality]
<div class="row mb-3 px-4 text-justify">
[..Last iteration of the repeated content..]
</div>
</div>
</div>
</div>
</div>
I trust this solution fits your requirements perfectly.