title: Inline-block display of divs with position relative
body: <p>I have a series of images each with his own overlay. How can I have them aligned like inline-blocks? I tried adding adding <code>display: inline-block;</code>to <code>.image-wrapper</code> but the images are always all positioned in the top left corner of the <code>div.container</code> (Here is a <a href="http://jsfiddle.net/klode/uhowp621/#base" rel="nofollow">jsfiddle</a>).</p>
  
  <p>Here are the html and css</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.container {
    position: relative;
  }
  .image-wrapper {
    position: relative;
    display: inline-block;
  }
  .tweetty {
    position: absolute;
    overflow: auto;
    top: 0;
    left: 0;
  }
  .image-vest {
    position: absolute;
    top: 0;
    left: 0;
    background-color: #00f;
    width: 220px;
    height: 300px;
    opacity: 0.4;
    color: #fff;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt;
  
    &lt;div class="image-wrapper"&gt;
      &lt;div class="tweetty"&gt;
        &lt;img src="http://www.picgifs.com/clip-art/cartoons/tweety/clip-art-tweety-191375.jpg" /&gt;
      &lt;/div&gt;
      &lt;div class="image-vest"&gt;Tweetty-one&lt;/div&gt;
    &lt;/div&gt;
  
    &lt;div class="image-wrapper"&gt;
      &lt;div class="tweetty"&gt;
        &lt;img src="http://www.picgifs.com/clip-art/cartoons/tweety/clip-art-tweety-191375.jpg" /&gt;
      &lt;/div&gt;
      &lt;div class="image-vest"&gt;Tweetty-two&lt;/div&gt;
    &lt;/div&gt;
  
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>EDIT:</p>
  
  <p>revised css with dfsq suggestion to remove <code>position:absolute;</code> from <code>.tweetty</code>.</p>
  
  <p>Quoting dfsq comment:
  "Elements with position absolute don't contribute to the width and height of their parent container. So the image-wrapper divs just collapse as if they were empty if all children have <code>position:absolute;</code> "</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.container {
    position: relative;
  }
  .image-wrapper {
    position: relative;
    display: inline-block;
  }
  .tweetty {
    overflow: auto;
    top: 0;
    left: 0;
  }
  .image-vest {
    position: absolute;
    top: 0;
    left: 0;
    background-color: #00f;
    width: 220px;
    height: 300px;
    opacity: 0.4;
    color: #fff;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt;
  
    &lt;div class="image-wrapper"&gt;
      &lt;div class="tweetty"&gt;
        &lt;img src="http://www.picgifs.com/clip-art/cartoons/tweety/clip-art-tweety-191375.jpg" /&gt;
      &lt;/div&gt;
      &lt;div class="image-vest"&gt;Tweetty-one&lt;/div&gt;
    &lt;/div&gt;
  
    &lt;div class="image-wrapper"&gt;
      &lt;div class="tweetty"&gt;
        &lt;img src="http://www.picgifs.com/clip-art/cartoons/tweety/clip-art-tweety-191375.jpg" /&gt;
      &lt;/div&gt;
      &lt;div class="image-vest"&gt;Tweetty-two&lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="image-wrapper"&gt;
      &lt;div class="tweetty"&gt;
        &lt;img src="http://www.picgifs.com/clip-art/cartoons/tweety/clip-art-tweety-191375.jpg" /&gt;
      &lt;/div&gt;
      &lt;div class="image-vest"&gt;Tweetty-three&lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>