当前位置 博文首页 > 如何使用CSS将项目放在其容器的底部_cuk0051的博客:css 容器底
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>
cs