Transitioned gallery for four images. A detailed tutorial on my blog
A Pen by Dudley Storey on CodePen.
| <div id="quad"> | |
| <figure> | |
| <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/rose-red-wine.jpg" alt="rose-red-wine"> | |
| <figcaption>Rose Red Wine</figcaption> | |
| </figure> | |
| <figure> | |
| <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/green-glass-bottle.jpg" alt> | |
| <figcaption>Green Glass Bottle</figcaption> | |
| </figure> | |
| <figure> | |
| <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/guinness-barrels.jpg" alt> | |
| <figcaption>Guinness Barrels, Dublin</figcaption> | |
| </figure> | |
| <figure> | |
| <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/crystal-skull-vodka.jpg" alt> | |
| <figcaption>Crystal Skull Vodka</figcaption> | |
| </figure> | |
| </div> | 
Transitioned gallery for four images. A detailed tutorial on my blog
A Pen by Dudley Storey on CodePen.
| var quadimages = document.querySelectorAll("#quad figure"); | |
| for(i=0; i<quadimages.length; i++) { | |
| quadimages[i].addEventListener('click', function(){ this.classList.toggle("expanded"); quad.classList.toggle("full") }); | |
| } | 
| <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> | 
| body { | |
| font-family: Avenir, sans-serif; margin: 0; | |
| background-color: #121; | |
| } | |
| div#quad { | |
| background-color: #000; | |
| font-size: 0; width: 60%; | |
| margin: 0 auto; | |
| box-shadow: 0 0 12px rgba(0,0,0,0.8); | |
| } | |
| div#quad figure { | |
| margin: 0; width: 50%; | |
| height: auto; transition: 1s; | |
| display: inline-block; | |
| position: relative; overflow: hidden; | |
| } | |
| div#quad figure:hover { cursor: pointer; z-index: 4; } | |
| div#quad figure img { width: 100%; height: auto; } | |
| div#quad figure:nth-child(1) { transform-origin: top left; } | |
| div#quad figure:nth-child(2) { transform-origin: top right; } | |
| div#quad figure:nth-child(3) { transform-origin: bottom left; } | |
| div#quad figure:nth-child(4) { transform-origin: bottom right; } | |
| div#quad figure figcaption { | |
| margin: 0; opacity: 0; | |
| background: rgba(0,0,0,0.3); | |
| color: #fff; padding: .3rem; | |
| font-size: 1.2rem; | |
| position: absolute; | |
| bottom: 0; width: 100%; | |
| transition: 1s 1s opacity; | |
| } | |
| .expanded { transform: scale(2); z-index: 5; } | |
| div#quad figure.expanded figcaption { opacity: 1; } | |
| div.full figure:not(.expanded) { pointer-events: none; } |