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

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

Given the following HTML:



        
24条回答
  •  时光取名叫无心
    2020-11-22 01:22

    If you do not know the height of child block:

    #parent {
        background:green;
        width:200px;
        height:200px;
        display:table-cell;
        vertical-align:bottom;
    }
    .child {
        background:red;
        vertical-align:bottom;
    }
    child

    http://jsbin.com/ULUXIFon/3/edit

    If you know the height of the child block add the child block then add padding-top/margin-top:

    #parent {
        background:green;
        width:200px;
        height:130px;
        padding-top:70px;
    }
    .child {
        background:red;
        vertical-align:
        bottom;
        height:130px;
    }
    child

提交回复
热议问题