Within my Bootstrap 4 layout, I have a column on the left that includes a dynamically generated .list-group
, which could potentially contain numerous .list-group-item
s.
On the right side, there is another column showcasing multiple cards inside a .row
. The number of cards displayed here can be quite extensive...
https://i.sstatic.net/d5KUu.png
<h3 class="text-secondary pb-3">Header</h3>
<div class="row">
<div class="col-12 col-sm-5 col-md-4 col-lg-4 col-xl-3 d-none d-sm-block" style="max-height: 7000px; overflow-y: scroll;">
<div class="list-group list-unstyled">
<a href="http://www.example.com/link" alt="View all post filed under example" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
<span><img src="https://www.google.com/s2/favicons?domain=example.com" class="mr-2">Example link</span>
<span class="badge badge-primary badge-pill">26</span>
</a>
<a href="http://www.example.com/link" alt="View all post filed under example" class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
<span><img src="https://www.google.com/s2/favicons?domain=example.com" class="mr-2">Example link</span>
<span class="badge badge-primary badge-pill">26</span>
</a>
</div>
</div>
<div class="col-12 col-sm-7 col-md-8 col-lg-8 col-xl-9>
<div class="row">
Many cards are present within this row, housed in .col-lg-4 columns.
</div>
</div>
</div>
If the content on the right-hand side exceeds that of the left-hand .list-group
, I want the height of the .list-group
to be limited and independently scrollable.
I've successfully achieved this by applying the CSS rule overflow-y: scroll;
to the containing column, which works well...
https://i.sstatic.net/bT0wr.gif
The challenge lies in manually setting the height of the column to something like max-height:7000px;
.
This approach runs the risk of cutting off the viewable area of the left-hand .list-group
based on the content's volume on the right. Ideally, the bottom of the left-hand .list-group
should align with the adjacent right-hand content, while still enabling independent scrolling...
https://i.sstatic.net/kTPdi.gif
Is there a way to ensure that if the left-hand column or the .list-group
is longer than the right-side content, its visible height adjusts to match that of the content on the right?
This adjustment should retain overflow-y: scroll;
for vertical scrolling if the list extends beyond the content on the right.
An ideal solution would utilize Bootstrap 4 styles without requiring custom CSS rules.