Html 使用 css 在另一个 div 的底部对齐 div
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8935575/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
align div in the bottom of another div using css
提问by Adham
I want to align the DIV c
in the bottom of the DIV b
not DIV a
我想DIV c
在DIV b
not的底部对齐DIV a
<div id="a">
<div id="b">
<div id="c">
Div c
</div>
</div>
</div>
回答by Blender
This should work:
这应该有效:
#b {
position: relative;
}
#c {
position: absolute;
bottom: 0px;
}
The trick is position: relative;
on the parent element. Without that, #c
will float away to the bottom of the page.
诀窍在于position: relative;
父元素。没有它,#c
将漂浮到页面底部。
回答by Max Spencer
It will take div#c
out of the flow of the document. It may not be perfect, but you can do something like the following:
它将div#c
脱离文档流。它可能并不完美,但您可以执行以下操作:
#b {
position: relative;
}
#c {
position: absolute;
bottom: 0;
}
回答by Humberto Pereira
Click in this link, maybe it can help you
点击这个链接,也许可以帮到你
#b {
display: -webkit-inline-flex;
display: -moz-inline-flex;
display: inline-flex;
-webkit-flex-flow: row nowrap;
-moz-flex-flow: row nowrap;
flex-flow: row nowrap;
-webkit-align-items: flex-end;
-moz-align-items: flex-end;
align-items: flex-end;}