CSS Property Value How to - height: auto; resize an image dynamically with CSS as the browser width/height changes








Question

We would like to know how to height: auto; resize an image dynamically with CSS as the browser width/height changes.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
img {<!--from  ww w  .  j  a  va  2s. c o  m-->
  max-width: 100%;
  height: auto;
  width: auto\9; /* ie8 */
}
</style>
</head>
<body>
  <img
    src="http://www.java2s.com/style/download.png" />
</body>
</html>

The code above is rendered as follows: