css 容器底部
It’s a rather common thing to do, and I had to do it recently.
这是一件很平常的事情,而我最近不得不这样做。
I was blindly assigning bottom: 0
to an element which I wanted to stick to the bottom of its parent.
我盲目地将bottom: 0
分配给我想坚持其父元素bottom: 0
的元素。
Turns out I was forgetting 2 things: setting position: absolute
on that element, and adding position: relative
on the parent.
原来我忘记了两件事:在该元素上设置position: absolute
,在父元素上添加position: relative
。
Example:
例:
<div class="container-element">
...
<div class="element-to-stick-to-bottom">
...
</div>
</div>
.element-to-stick-to-bottom {
position: absolute;
bottom: 0;
}
.container-element {
position: relative;
}
翻译自: https://flaviocopes.com/css-how-to-put-item-bottom-container/
css 容器底部