Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 4 card-footer does not align to the bottom of the page

I am using Bootsrap 4 cards' class 'card-footer', but the footer is not aligning to the bottom of the page.

Here is the link to the js fiddle

<div class="container">
   <div class="card text-center">
     <div class="card-header">Featured</div>
     <div class="card-body">
       <h5 class="card-title">Special title treatment</h5>
       <p class="card-text">This text should be equi-distance from header 
       and footer. </p>
       <p class="card-text">
       Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam 
       sapien sem, ornare ac, nonummy non, lobortis a enim. Nam sed 
       tellus id magna elementum tincidunt. Pellentesque habitant morbi 
       tristique senectus et netus et malesuada fames ac turpis egestas. 
       Aliquam ornare wisi eu metus. In enim a arcu imperdiet malesuada. 
       Nam quis nulla. Vivamus luctus egestas leo. 
       </p>
   </div>
   <div class="card-footer text-muted">
    This footer should be at the bottom
  </div>
 </div>
</div>
like image 812
Janardhan Maithil Avatar asked Dec 23 '22 04:12

Janardhan Maithil


2 Answers

The card needs to be full height. Bootstrap 4 has a h-100 class for height:100%...

<div class="container h-100">
<div class="card h-100 text-center">
  <div class="card-header">
    Featured
  </div>
  <div class="card-body">
    <h5 class="card-title">Special title treatment</h5>
    ...
  </div>
  <div class="card-footer text-muted">
    This footer should be at the bottom
  </div>
</div>
</div>

https://jsfiddle.net/eqfxk9wo/

like image 154
Zim Avatar answered Jan 05 '23 18:01

Zim


Easiest way I think is to give the card-footer a class of mt-auto

  <div class="card-footer mt-auto" >
    Whatever
  </div>
like image 36
yoshinator Avatar answered Jan 05 '23 17:01

yoshinator