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

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

Given the following HTML:



        
24条回答
  •  借酒劲吻你
    2020-11-22 01:34

    Yes you can do this without absolute positioning and without using tables (which screw with markup and such).

    DEMO
    This is tested to work on IE>7, chrome, FF & is a really easy thing to add to your existing layout.

    Some content you don't want affected by the "bottom floating" div
    supports not just text
    Some other content you want kept to the bottom
    this is in a div
    #container {
        height:100%;
        border-collapse:collapse;
        display : table;
    }
    
    .foot {
        display : table-row;
        vertical-align : bottom;
        height : 1px;
    }
    

    It effectively does what float:bottom would, even accounting for the issue pointed out in @Rick Reilly's answer!

提交回复
热议问题