Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Align child to the bottom of the parent in CSS (Flexbox)

Tags:

html

css

flexbox

I am using flexbox and I am trying to align a child division to the bottom of a parent division. I can't find a solution. Here's an example of what I tried.

.container {
    display: flex;
    flex-direction: column;
}

.top {
    height: 70%;
}

.bottom {
    height: 30%;
    justify-content: flex-end;
}
<div class='container'>
    <div class='top'>
        <p>Content to go on top</p>
    </div>
    <div class='bottom'>
        <p>Content to go on bottom</p>
    </div>
</div>

This is what I end up with: I am trying to make that happen to the left sidebar

like image 743
Niaz M. Sameer Avatar asked Oct 29 '25 09:10

Niaz M. Sameer


1 Answers

You need to make .bottom a flex container to be able to use justify-content

.container {
  display: flex;
  flex-direction: column;
  height: 300px;
  border:1px solid;
}

.top {
  height: 70%;
  border:1px solid;
}

.bottom {
  height: 30%;
  display: flex; /*added this*/
  flex-direction: column; /*added this*/
  justify-content: flex-end;
  border:1px solid;
}
<div class='container'>
  <div class='top'>
    <p>Content to go on top</p>
  </div>
  <div class='bottom'>
    <p>Content to go on bottom</p>
  </div>
</div>
like image 94
Temani Afif Avatar answered Oct 31 '25 00:10

Temani Afif



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!