Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I align the button to the bottom of the row/column in bootstrap?

I have row with 4 columns each with a heading and some text. Most of the columns have a similar amount of text and push the button in their column down to match the rest of the columns. However one column has less text and doesn't push the button down far enough.

enter image description here

Is there a way to align the button to the bottom of the row? I would like to achieve this and keep it responsive at the same time so it looks like this when the screen is smaller:

enter image description here

This is my markup of the page just now:

<div class="container">
  <div class="row">
    <div class="col-md-3">
      <h2>Heading</h2>
      <p>text here</p>
      <p><a class="btn btn-default" href="#" role="button">View details >></a></p>
    </div>
    <div class="col-md-3">
      <h2>Heading</h2>
      <p>text here</p>
      <p><a class="btn btn-default" href="#" role="button">View details >></a></p>
    </div>
    <div class="col-md-3">
      <h2>Heading</h2>
      <p>less text here</p>
      <p><a class="btn btn-default more" href="#" role="button">View details >></a></p>
    </div>
    <div class="col-md-3">
      <h2>Heading</h2>
      <p>text here</p>
      <p><a class="btn btn-default" href="#" role="button">View details >></a></p>
    </div>
  </div>
</div>
like image 642
Sheldon Avatar asked May 29 '14 21:05

Sheldon


People also ask

How do I move a button to the bottom in Bootstrap?

Just add the align-self-end class to item to align at the bottom.

How do you align an element to the bottom of a Bootstrap column?

You can use align-items-end from the new Bootstrap 4 flexbox utilities... Also, auto margins work inside flexbox. There you could use mt-auto (margin-top:auto) to "push" the col-* to the bottom. Save this answer.

How do you position a button to the bottom right in CSS?

The “display” and “position” property of CSS is utilized to adjust the button at the bottom of the div. Using the position property, set the value of position to parent element as “relative” and child element as “absolute”, and for the display property, set it to value as “flex”.


1 Answers

There are several ways this can be done:

  • Give the containers a fixed height. This is not ideal as in order for it to look nice you will have to set different heights for each of the breakpoints.
    You will also need to set the button to position: absolute, bottom: 0 and add some bottom padding/margin.

  • Use some javascript to match the heights using something like match height. You will also need to set the positions as in the previous point.

  • Add an additional row and repeat your buttons within 4 new cols. Then show or hide your original buttons and the new ones using bootstraps responsive classes.

like image 162
Tims Avatar answered Oct 27 '22 16:10

Tims