Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap - I don't want columns to have the same height

In this bootstrap 4 example the 2 columns have the same height. I do not want this. Is there a quick fix for this ?

    <div class="col-lg-3 card bg-faded">
      <h1><small>Some favorites</small></h1>
      <ul>
        <li>Celery root</li>
        <li>Spaghetti Squash</li>
        <li>Killer Mushrooms</li>
      </ul>
    </div>

    <div class="col-lg-9">
      <h1>Wild & Wicky Vegetables</h1>
      <p>Kale c.....t.</p>
    </div>
</div><!--row-->
like image 797
Mohammed Ait Avatar asked Jun 22 '17 23:06

Mohammed Ait


2 Answers

Bootstrap 5 (update 2021)

Bootstrap 5 is still flexbox based so columns in a row are equal height. Therefore d-block can still be used to "disable" flexbox and use float-start to float columns.

Bootstrap 4 (original answer)

Yes, you can use d-block on the row, and float-left on the columns to make it work the Bootstrap 3.x way with floated columns instead of flexbox..

<div class="row d-block">
    <div class="col-lg-3 float-left">
        ..
    </div>
    <div class="col-lg-9 float-left">
        ..
    </div>
</div>

https://codeply.com/go/Ghhq1NbMDG


Related:
Bootstrap 4 Columns float style like Bootstrap 3 is it possible?
Empty vertical space between columns in Bootstrap 4

like image 122
Zim Avatar answered Nov 13 '22 12:11

Zim


Actually, a simpler solution is to add 'h-100' class to the column you don't want to share the same height with. This makes the column 100% height of itself, not sharing the height of the other column in the row.

like image 39
Phil Owen Avatar answered Nov 13 '22 11:11

Phil Owen