title: Responsive, pure CSS hover image gallery
body: <p>I want to make responsive image gallery. That will display extended image on thumbnail hover. Gallery can't use any JS this is requirement.</p>
  
  <p>But there is 1 little problem. Gallery needs to be responsive.
  That means expanded image have to be the same size as the default image that is responsive and resize on smaller devices.</p>
  
  <p>Here is my html code</p>
  
  <pre><code>&lt;div class="container"&gt;&lt;/div&gt;
  &lt;div class="container"&gt;
  
    &lt;div id="gallery-photo-container"&gt;
      &lt;img src="http://imgur.com/60BBDre.jpg"&gt;
      &lt;div class="gallery-thumbnail-image"&gt;
        &lt;img src="http://imgur.com/60BBDre.jpg"&gt;
        &lt;div class="gallery-main-image"&gt;
          &lt;img src="http://imgur.com/60BBDre.jpg"&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="gallery-thumbnail-image"&gt;
        &lt;img src="http://i.imgur.com/C7SFJxy.jpg"&gt;
        &lt;div class="gallery-main-image"&gt;
          &lt;img src="http://i.imgur.com/C7SFJxy.jpg"&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="gallery-thumbnail-image"&gt;
        &lt;img src="http://i.imgur.com/aa5kiAi.jpg"&gt;
        &lt;div class="gallery-main-image"&gt;
          &lt;img src="http://i.imgur.com/aa5kiAi.jpg"&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="gallery-thumbnail-image"&gt;
        &lt;img src="http://imgur.com/TWLJOVv.jpg"&gt;
        &lt;div class="gallery-main-image"&gt;
          &lt;img src="http://imgur.com/TWLJOVv.jpg"&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Absolute approach</strong></p>
  
  <p>I have almost done it, using absolute position and positioning with top attribute. But on resize expanded image is the size of left container beginning to the right end of the page.</p>
  
  <p>Here is my <a href="https://plnkr.co/edit/KFNTeSZbhlJmHFqQ0t6P?p=info" rel="nofollow">DEMO1</a> and CSS.</p>
  
  <pre><code>.gallery-thumbnail-image:hover &gt; .gallery-main-image {
    visibility: visible;
    opacity: 1;
  }
  
  .gallery-thumbnail-image {
    display: inline-block;
  }
  
  #gallery-photo-container .gallery-thumbnail-image &gt; img {
    width: 79px;
  }
  
  #gallery-photo-container img {
    max-width: 100%;
  }
  
  .gallery-main-image {
    position: absolute;
    visibility: hidden;
    top: 18px;
    left: 18px;
    margin-right: 8px;
  }
  
  .container {
    width: 50%;
  }
  
  #gallery-photo-container {
    border: 1px solid black;
    padding: 10px;
  }
  </code></pre>
  
  <p><strong>Relative approach</strong></p>
  
  <p>I think it can be done it too, by using relative position and positioning with bottom attribute. But here the problem is that thumbnail image container is resizing to the expanded image size on hover. And the bottom attribute value is screen size dependent.</p>
  
  <p>In this <a href="https://plnkr.co/edit/f3kx4Y?p=preview" rel="nofollow">DEMO2</a> you have to click on a thumbnail because they are jumping. And here is CSS for relative approach. </p>
  
  <pre><code>.gallery-thumbnail-image:hover &gt; .gallery-main-image {
    display: block;
    opacity: 1;
  }
  
  .gallery-thumbnail-image {
    display: inline-block;
  }
  
  #gallery-photo-container .gallery-thumbnail-image &gt; img {
    width: 79px;
  }
  
  #gallery-photo-container img {
    width: 100%;
  }
  
  .gallery-main-image {
    position: relative;
    display: none;
    bottom: 373px;
  }
  </code></pre>
  
  <p>So, could it be done responsive way with one of these two approaches? Or maybe you have another idea. I'm looking forward for your help.</p>