将元素锁定到包含div的底部

时间:2011-02-27 21:08:31

标签: html css

#Container {
    width: 500px;
    height: 600px;
}

#TheElement {
    width: 500px;
    height: 100px;
    background-color: #000000;
}

如何将#TheElement锁定到#Container的最底部,无论容器内的其他内容如何,​​没有一堆边缘欺骗?

1 个答案:

答案 0 :(得分:63)

您可以使用relative absolute positioning

http://jsfiddle.net/gzJM6/

#Container {
    width: 500px;
    height: 600px;
    position: relative
}

#TheElement {
    width: 500px;
    height: 100px;
    background-color: #000000;
    position: absolute;
    bottom: 0;
    left: 0;
}