Align button at the bottom of div using CSS

后端 未结 4 951
耶瑟儿~
耶瑟儿~ 2020-12-04 10:09

I want to align my button at the bottom right corner of my div. How can I do that?

\"enter

4条回答
  •  无人及你
    2020-12-04 10:47

    CSS3 flexbox can also be used to align button at the bottom of parent element.

    Required HTML:

    Necessary CSS:

    .container {
      justify-content: space-between;
      flex-direction: column;
      height: 100vh;
      display: flex;
    }
    .container .btn-holder {
      justify-content: flex-end;
      display: flex;
    }
    

    Screenshot:

    Useful Resources:

    • Specs
    • MDN
    • CSS Tricks

    * {box-sizing: border-box;}
    body {
      background: linear-gradient(orange, yellow);
      font: 14px/18px Arial, sans-serif;
      margin: 0;
    }
    .container {
      justify-content: space-between;
      flex-direction: column;
      height: 100vh;
      display: flex;
      padding: 10px;
    }
    .container .btn-holder {
      justify-content: flex-end;
      display: flex;
    }
    .container .btn-holder button {
      padding: 10px 25px;
      background: blue;
      font-size: 16px;
      border: none;
      color: #fff;
    }

    Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet... Lorem ip sum dolor sit amet...

提交回复
热议问题