这是一件很常见的场景,最近俺还犯了一个小错误。
俺盲目地将bottom: 0赋值给一个元素,俺想把它固定在其父元素的底部。
但是…..
一直没有效果,后来俺才发现。
原来俺忘记了两件事:在元素上设置绝对位置和在父元素上添加相对位置。

最后实现的代码如下:
HTML
<div class="container-element">
...
<div class="element-to-stick-to-bottom">
...
</div>
</div>
CSS
.element-to-stick-to-bottom {
position: absolute;
bottom: 0;
}
.container-element {
position: relative;
}