How can I position my div at the bottom of its container?

前端 未结 24 2477
广开言路
广开言路 2020-11-22 00:46

Given the following HTML:



        
24条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 01:32

    For those only have one child in the container, you can use the table-cell and vertical-align approach which worked reliably for positioning a single div at the bottom of its parent.

    Note that using table-footer-group as other answers mentioned will break the height calculation of parent table.

    #container {
        display: table;
        width: 100%;
        height: 200px;
    }
    #item {
        display: table-cell;
        vertical-align: bottom;
    }
    Single bottom item

提交回复
热议问题