Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 4 aligning row to the bottom of a container

How do I align a bootstrap row to the bottom of a container?

Like this: Like this

HTML

<main class="bd-masthead container-fluid" id="" role="main" style="padding-top:5rem;">
  <div class="row">
    <div class="col">
      <h1 class="text-light">
        LukeBank
      </h1>
    </div>
  </div>
  <div class="row" style="padding-top:10px">
    <div class="col">
      <button type="button" class="btn btn-outline-light">Button</button>
    </div>
  </div>
</main>

CSS

html, body {
  height: 100%;
  width: 100%;
}

main {
  height: 100%;
  background-image: url(/img/frontpage.bg.jpg); 
  background-position: center center;
  background-size: cover; 
}

.otherpart {
  height: 100%;
  background-color: white;
  background-position: center bottom;
  background-size: cover;  
}

I tried to use .align-bottom, but it didn't work.

like image 342
Luke Won Avatar asked Dec 09 '17 06:12

Luke Won


People also ask

What is Col MD 6 in Bootstrap?

col-sm- (small devices - screen width equal to or greater than 576px) . col-md- (medium devices - screen width equal to or greater than 768px) . col-lg- (large devices - screen width equal to or greater than 992px)

How do I center a row in Bootstrap?

1 — Vertical Center Using Auto Margins One way to vertically center is to use my-auto . This will center the element within it's flexbox container (The Bootstrap 4 . row is display:flex ). For example, h-100 makes the row full height, and my-auto will vertically center the col-sm-12 column.


4 Answers

If you are using bootstrap 4, you can use the class - fixed-bottom.

Check :

https://getbootstrap.com/docs/4.4/utilities/position/#fixed-bottom

Fixed footer in Bootstrap

like image 117
saurabh Avatar answered Oct 27 '22 18:10

saurabh


For bootstrap 4, you can use the shorthand classes and set mt-auto, which will have the effect of aligning your element to the bottom of the container.

https://getbootstrap.com/docs/4.0/utilities/spacing/

like image 28
staxim Avatar answered Oct 27 '22 19:10

staxim


To align to bottom you could try with flexbox:

display: flex;
flex-direction: column;
justify-content: space-between;

or if you just have one element

display: flex;
flex-direction: column;
justify-content: flex-end;
like image 37
Christian Michael Avatar answered Oct 27 '22 17:10

Christian Michael


Try to add align-self-end class to the div with col class

<div class="col align-self-center">
like image 42
Бекзод Avatar answered Oct 27 '22 19:10

Бекзод