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

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

Given the following HTML:



        
24条回答
  •  萌比男神i
    2020-11-22 01:47

    Just because this hasn't been mentioned at all, what usually works well in situations like yours:

    Placing the copyright-div after the container-div

    You would only have to format the copyright-div in a similar way to the other container (same overall width, centering, etc.), and all is fine.

    CSS:

    #container, #copyright {
        width: 1000px;
        margin:0 auto;
    }
    

    HTML:

    The only time this might not be ideal is when your container-div is declared with height:100%, and the user would need to scroll down to see the copyright. But even still you could work around (e.g. margin-top:-20px - when the height of your copyright element is 20px).

    • No absolute positioning
    • No table layout
    • No crazy css, that looks different in every other browser (well IE at least, you know)
    • Simple and clear formatting

    Aside: I know the OP asked for a solution that "... sticks to the bottom of the 'container' div ...", and not something under it, but come on, people are looking for good solutions here, and this is one!

提交回复
热议问题