HTML Element Style How to - fill div with Image








Question

We would like to know how to fill div with Image.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
body, .row, img {<!-- w w  w  .jav  a2 s. c o  m-->
  padding: 0;
  margin: 0;
  border: none;
}

.row {
  width: 80%;
  background-color: orange;
  display: table;
}

img {
  width: 50%;
  vertical-align: top;
}
</style>
</head>
<body>
  <div class="row">
    <img src="http://www.java2s.com/style/download.png" />
  </div>
</body>
</html>

The code above is rendered as follows: