CSS Layout How to - Create relative positioning with percentage values in top property








Question

We would like to know how to create relative positioning with percentage values in top property.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.one {<!--  ww w.j  av a2  s  .  co m-->
  position: static;
}

.two {
  position: absolute;
  top: 25%;
}

.three {
  position: absolute;
  top: 35%;
}
</style>
</head>
<body>
  <div class="one">some blurb to go</div>
  <div class="two">more blurb to go</div>
  <div class="three">even more of the stuff</div>
</body>
</html>

The code above is rendered as follows: