HTML Element Style How to - Create thumbnail sizing for images








Question

We would like to know how to create thumbnail sizing for images.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.thumbnail {<!--   www . j a va  2  s  .  c o  m-->
  display: block;
  overflow: hidden;
  height: 20px;
  width: 20px;
}

.thumbnail img {
  display: block;
  height: 100%;
}
</style>
</head>
<body>
  <div class="thumbnail">
    <img
      src="http://www.java2s.com/style/download.png">
  </div>
</body>
</html>

The code above is rendered as follows: