Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fixed height Bootstrap card with vertically-scrollable card-text

How can I achieve a fixed height bootstrap 4 card that has a vertically-scrollable card-text portion?

<div class="card" style="height:300px">        <-- non scrollable
    <div class="card-body">                    <-- non scrollable
        <h5 class="card-title">Card title</h5> <-- non scrollable
        <p class="card-text">This portion and only this portion will have a very long text so much so that the vertical scroll bar may appear when required.</p>
    </div>
</div>
like image 522
Yaskov Avatar asked Oct 29 '25 00:10

Yaskov


1 Answers

You have to wrap the .card-text with a scrollable container. Then set the scrollable container overflow-y: auto;.

Don't forget to set the height for scrollable container too. Scroll bar will not appear if the height is auto as default.

https://codepen.io/blackcityhenry/pen/LXOOgW

like image 174
blackcityhenry Avatar answered Oct 30 '25 16:10

blackcityhenry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!