HTML Element Style How to - Proportionally resize div with an image inside








Question

We would like to know how to proportionally resize div with an image inside.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#footer {<!--from w  ww . j a  v  a 2 s . co m-->
  position: absolute;
  bottom: 0;
  margin: 0 auto;
  padding: 0;
  heigh: 112px;
  width: 100%;
  z-index: 97;
}

#sponsors {
  text-align: center;
  margin: 0 auto 6px;
  padding: 0px 0px 0px 0px;
}

#sponsors img {
  width: 16%;
}

#sponsors img:hover {
  opacity: 0.6;
}
</style>
</head>
<body>
  <div id="footer">
    <div id="sponsors">
      <a href="" target="_blank"><img src="http://www.java2s.com/style/download.png"></a>
      <a href="" target="_blank"><img src="http://www.java2s.com/style/download.png"></a>
      <a href="" target="_blank"><img src="http://www.java2s.com/style/download.png"></a>
      <a href="" target="_blank"><img src="http://www.java2s.com/style/download.png"></a>
      <a href="" target="_blank"><img src="http://www.java2s.com/style/download.png"></a>
      <a href="" target="_blank"><img src="http://www.java2s.com/style/download.png"></a>
      <a href="" target="_blank"><img src="http://www.java2s.com/style/download.png"></a>
      <a href="" target="_blank"><img src="http://www.java2s.com/style/download.png"></a>

    </div>
  </div>
</body>
</html>

The code above is rendered as follows: