Page Widget How to - Put text on top of image








Question

We would like to know how to put text on top of image.

Answer


<!--from www  .j  av  a  2  s .  co  m-->
<!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: