To prevent the default stretch alignment that makes all columns equal in height, add align-items-start
. This will allow for a sticky behavior to be applied.
.container-fluid {
border:1px solid;
}
.sticky-top {
border:1px solid red;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet>
<div class="container-fluid">
<div class="row align-items-start">
<div class="col-sm-3 sticky-top"> <!-- this grid should be sticky -->
<div class="card text-left">
<div class="card-body">
<h4 class="card-title">Title</h4>
<p class="card-text">Body</p>
</div>
</div>
</div>
<div class="col-sm-6" style="min-height:800px;">ssdfjosdfjsl</div>
<div class="col-sm-3">ssdfjosdfjsl</div>
</div>
</div>
The issue of default alignment can be clearly seen with borders:
.container-fluid {
border:1px solid;
}
.sticky-top {
border:1px solid red;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 sticky-top"> <!-- this grid should be sticky -->
<div class="card text-left">
<div class="card-body">
<h4 class="card-title">Title</h4>
<p class="card-text">Body</p>
</div>
</div>
</div>
<div class="col-sm-6" style="min-height:800px;">ssdfjosdfjsl</div>
<div class="col-sm-3">ssdfjosdfjsl</div>
</div>
</div>
You can also choose to keep the default alignment and make the card sticky:
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<div class="container-fluid">
<div class="row">
<div class="col-sm-3">
<div class="card text-left sticky-top">
<div class="card-body">
<h4 class="card-title">Title</h4>
<p class="card-text">Body</p>
</div>
</div>
</div>
<div class="col-sm-6" style="min-height:800px;">ssdfjosdfjsl</div>
<div class="col-sm-3">ssdfjosdfjsl</div>
</div>
</div>