HTML Element Style How to - Stack images








Question

We would like to know how to stack images.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
img {<!--  ww w  .j  a va 2 s .co m-->
  width: 100%;
  max-width: 100%;
  height: auto;
}

#wrapper {
  width: 700px;
  max-width: 90%;
  margin: 0 auto;
}

#main-column-left {
  max-width: 66%;
  float: left;
}

#main-column-right {
  max-width: 33%;
  float: right;
  border-collapse: collapse;
}

#news-feature {
  width: 400px;
  height: 300px;
  float: left;
  display: block;
}

#news-item-four {
  width: 200px;
  max-width: 100%;
  max-height: 100%;
  float: left;
  margin-bottom: 10px;
}

#news-item-five {
  width: 200px;
  float: left;
}

.clear {
  clear: both;
}
</style>
</head>
<body>
  <div id="wrapper">
    <div id="main-column-left">
      <div id="news-feature">
        <img src="http://www.java2s.com/style/download.png" />
      </div>
    </div>
    <div id="main-column-right">
      <div id="news-item-four">
        <img src="http://www.java2s.com/style/download.png" />
      </div>
      <div id="news-item-five">
        <img src="http://www.java2s.com/style/download.png" />
      </div>
    </div>
    <br class="clear" />
  </div>
</body>
</html>

The code above is rendered as follows: