Aligning to the bottom in flexbox

前端 未结 2 1176
借酒劲吻你
借酒劲吻你 2020-12-01 20:13

I\'m have containers that should change height dynamically depending on the content. For all containers in a given row, the bottom text should all be fixed to the bottom re

相关标签:
2条回答
  • 2020-12-01 20:53

    If you change your .caption code to:

    .caption {
      flex: 1;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
    }
    

    and then add:

    .flex-item {
      display: flex;
      flex-direction: column;
    }
    
    0 讨论(0)
  • 2020-12-01 21:00

    You need to make the parent a flex container:

    .flex-list .flex-row .flex-item-wrapper .flex-item {
        width: 100%;
        height: 100%;
        display: flex;                      /* new */
        flex-direction: column;             /* new */
    }
    

    Then, tell the .caption element to fill available height:

    .caption { flex: 1; }
    

    Revised Fiddle

    It's a common question. Here are other options:

    • Methods for Aligning Flex Items
    • Flexbox align to bottom
    • Pin a flex item to the bottom of the container
    • Pin element (flex item) to bottom of container
    • Pin element to the bottom of the container
    • Pin a button to the bottom corner of a container
    • Aligning element to bottom with flexbox
    • Aligning items to the bottom using flex
    • Align content of flex items to bottom
    • Align content in a flex container to the bottom
    • Aligning element to bottom with flexbox
    • Nested flexbox, align-items do not flex-end
    • align-content: flex-end not shifting elements to container bottom
    • Sticky footer with flexbox
    • Why isn't align-self aligning my div to the bottom of my flexbox?
    • How to bottom-align an element inside a flex item?
    • Flexbox difficulties aligning icons to bottom of container
    • Make an item stick to the bottom using flex in react-native
    • Equal height columns and align last item to bottom
    0 讨论(0)
提交回复
热议问题