How do I align a bootstrap row to the bottom of a container?
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.
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)
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.
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
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/
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;
Try to add align-self-end class to the div with col class
<div class="col align-self-center">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With