CSS Layout How to - Absolute position inside parent








Question

We would like to know how to absolute position inside parent.

Answer


<!--   w  w w. j  a v a  2  s.  c  om-->
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.image {
  position: relative;
}

.wrapper {
  position: absolute;
  top: 50%;
  left: 0;
}

h2 {
  margin: 0;
  padding: 0;
}
</style>
</head>
<body>
  <div class="image">
    <img src="http://www.java2s.com/style/download.png" />
    <div class="wrapper">
      <h2>Title</h2>
    </div>
  </div>
</body>
</html>

The code above is rendered as follows: