Align an element to bottom with flexbox

前端 未结 8 1897
陌清茗
陌清茗 2020-11-22 15:34

I have a div with some children:

heading 1

heading 2

Some

8条回答
  •  情话喂你
    2020-11-22 16:35

    1. Style parent element: style="display:flex; flex-direction:column; flex:1;"

    2. Style the element you want to stay at bottom: style="margin-top: auto;"

    3. Done! Wow. That was easy.

    Example:

    // For demo, not necessary
    // Parent element // Target element
    ... 5 more identical divs, for demo ...

    Demo: https://codepen.io/ferittuncer/pen/YzygpWX

提交回复
热议问题