使用css将div放在另一个div的底部

Adh*_*ham 8 html css

我要对齐的DIV c中的底部DIV bDIV a

<div id="a">
   <div id="b">
        <div id="c">
              Div c
        </div>
   </div>
</div>
Run Code Online (Sandbox Code Playgroud)

Ble*_*der 39

这应该工作:

#b {
  position: relative;
}

#c {
  position: absolute;
  bottom: 0px;
}
Run Code Online (Sandbox Code Playgroud)

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

  • 该死的,打败了我! (3认同)

Max*_*cer 8

它将div#c取消文档的流程.它可能不完美,但您可以执行以下操作:

#b {
  position: relative;
}

#c {
  position: absolute;
  bottom: 0;
}
Run Code Online (Sandbox Code Playgroud)