0

How do I use flexbox to position the button on the very bottom? Or should I use position: absolute?

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

button {
  align-self: center;
}
    <html>
      <body>
        <div class="container">
          <p> Paragraph one </p>
          <p> Paragraph two </p>
          <button > on the very bottom </button>
        </div>
      </body>
    </html>
martins
  • 9,669
  • 11
  • 57
  • 85

1 Answers1

1

Using flexbox, add flex-grow: 1; to the second paragraph.

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

p.flex-bottom {
  flex-grow: 1;
}

button {
  align-self: center;
}
    <html>
      <body>
        <div class="container">
          <p> Paragraph one </p>
          <p class="flex-bottom"> Paragraph two </p>
          <button > on the very bottom </button>
        </div>
      </body>
    </html>