HTML Element Style How to - Align div to bottom of a sibling div without knowing the sibling div's height








Question

We would like to know how to align div to bottom of a sibling div without knowing the sibling div's height.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.wrapper {<!--  ww  w . j  a v  a2s  .  c  om-->
  border: solid 1px;
  margin: 10px auto;
  width: 100%;
  padding: 10px;
  position: relative;
}

.left {
  margin-right: 160px;
  border: solid 1px;
}

.right {
  position: absolute;
  bottom: 10px;
  right: 10px;
  border: solid 1px;
  width: 150px;
}
</style>
</head>
<body>
<body>
  <div class="wrapper">
    <div class="right">
      <h2>Right</h2>
    </div>
    <div class="left">
      <h2>Left</h2>
      <br/>this
      <br/>is
      <br/>a
      <br/>test
      <br/>
      <br/>
      <br/>
    </div>
  </div>
</body>
</html>
</body>
</html>

The code above is rendered as follows: