HTML Element Style How to - Make div absolute right








Question

We would like to know how to make div absolute right.

Answer


<!-- w  ww . j  a  va 2s.c  om-->
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.A {
  background: green;
}

.B {
  background: yellow;
  position: relative;
}

.C {
  background: red;
  position: absolute;
  top: 0;
  right: 0;
}

.container {
  position: relative;
}
</style>
</head>
<body>
  <div class="container">
    <div class="A">A</div>
    <div class="B">B</div>
    <div class="C">C</div>
  </div>
</body>
</html>

The code above is rendered as follows: