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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 12:38:46  来源:igfitidea点击:

align div in the bottom of another div using css

csshtml

提问by Adham

I want to align the DIV cin the bottom of the DIV bnot DIV a

我想DIV cDIV bnot的底部对齐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, #cwill float away to the bottom of the page.

诀窍在于position: relative;父元素。没有它,#c将漂浮到页面底部。

回答by Max Spencer

It will take div#cout 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;}

http://jsfiddle.net/rudiedirkx/7FGKN/

http://jsfiddle.net/rudiedirkx/7FGKN/