HTML Element Style How to - Resize horizontally aligned images








Question

We would like to know how to resize horizontally aligned images.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.image {<!--  w w  w.  jav  a  2  s . com-->
  display: block;
  float: left;
  max-width: 200px;
  width: 50%;
  position: relative;
}

#parent {
  overflow: hidden;
  width: 100%;
  display: block;
}
</style>
</head>
<body>
  <div id="parent">
    <img class="image" src="http://www.java2s.com/style/download.png"> 
    <img class="image" src="http://www.java2s.com/style/download.png">
  </div>
</body>
</html>

The code above is rendered as follows: