How to align content of a div to the bottom

后端 未结 26 2532
挽巷
挽巷 2020-11-22 01:13

Say I have the following CSS and HTML code:

26条回答
  •  遇见更好的自我
    2020-11-22 01:43

    If you're not worried about legacy browsers use a flexbox.

    The parent element needs its display type set to flex

    div.parent {
      display: flex;
      height: 100%;
    }
    

    Then you set the child element's align-self to flex-end.

    span.child {
      display: inline-block;
      align-self: flex-end;
    }
    

    Here's the resource I used to learn: http://css-tricks.com/snippets/css/a-guide-to-flexbox/

提交回复
热议问题