"Pure CSS Sticky Sidebars"
Bootstrap 4.1.1 Snippet by GSTSTUDIO

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<article>
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="title-section">
<h1>Multiple Stacking Sticky Sidebars with Bootstrap 4</h1>
<p class="lead">This is 100% CSS</p>
</div>
</div>
</div>
<div class="row">
<div class="col-1 has-10-items">
<div class="sidebar-item">
<div class="make-me-sticky">
<h4>Item 1</h4>
</div>
</div>
<div class="sidebar-item">
<div class="make-me-sticky">
<h4>Item 2</h4>
</div>
</div>
<div class="sidebar-item">
<div class="make-me-sticky">
<h4>Item 3</h4>
</div>
</div>
<div class="sidebar-item">
<div class="make-me-sticky">
<h4>Item 4</h4>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
.content-section {
min-height: 2000px;
}
.sidebar-section {
position: absolute;
height: 100%;
width: 100%;
}
.sidebar-item {
position: absolute;
top: 0;
left: 0;
width: 100%;
}
.has-4-items .sidebar-item {
height: 25%;
}
.has-4-items .sidebar-item:nth-child(2) {
top: 25%;
}
.has-4-items .sidebar-item:nth-child(3) {
top: 50%;
}
.has-4-items .sidebar-item:nth-child(4) {
top: 75%;
}
.has-3-items .sidebar-item {
height: 33.333333%;
}
.has-3-items .sidebar-item:nth-child(2) {
top: 33.333333%;
}
.has-3-items .sidebar-item:nth-child(3) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: