JSFiddle - React, Tailwind, and code Playground
HTML
<div class="wrapper">
<ul id="hexGrid">
<li class="hex">
<div class="hexFront">
<div class="hexIn">
<div class="hexInner">
<img src="https://picsum.photos/500/?random" alt="#" />
</div>
</div>
</div>
<div class="hexBack">
<div class="hexIn">
<div class="hexInner">
<p> backside </p>
</div>
</div>
</div>
</li>
<li class="hex">
<div class="hexFront">
<div class="hexIn">
<div class="hexInner">
<div class="hexIn hexInIn">
</div>
</div>
</div>
</div>
<div class="hexBack">
<div class="hexIn hexInIn">
<div class="hexInner">
<p> backside </p>
</div>
</div>
</div>
</li>
<li class="hex">
<div class="hexFront">
<div class="hexIn">
<div class="hexInner">
<img src="https://picsum.photos/500/?random" alt="#" />
</div>
</div>
</div>
<div class="hexBack">
<div class="hexIn">
<div class="hexInner">
<p> backside </p>
</div>
</div>
</div>
</li>
<li class="hex">
<div class="hexFront">
<div class="hexIn">
<div class="hexInner">
<img src="https://picsum.photos/500/?random" alt="#" />
</div>
</div>
</div>
<div class="hexBack">
<div class="hexIn">
<div class="hexInner">
<p> backside </p>
</div>
</div>
</div>
</li>
</ul>
</div>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script>
CSS
html, body {
font-family: Segoe, "Segoe UI", "DejaVu Sans", "Trebuchet MS", "sans-serif";
background-color: #1c1c1c;
height: 100%;
}
.wrapper {
display: flex;
height: 100%;
justify-content: center;
align-items: center;
}
#hexGrid {
display: flex;
flex-wrap: wrap;
width: 50%;
padding-bottom: 5.5%;
overflow: hidden;
list-style-type: none;
}
.hex {
position: relative;
visibility: hidden;
outline: 1px solid transparent;
width: 25%;
}
.hex:nth-child(7n + 5) {
margin-left: 12.5%;
}
.hex::after {
content: "";
display: block;
padding-bottom: 86.602%;
}
.hexFront, .hexBack {
perspective: 800;
transform-style: preserve-3d;
transform: rotateY(0deg);
backface-visibility: hidden;
transition: transform 1s ease-out, opacity 0.5s ease-out;
}
.hexBack {
opacity: 0;
transform: rotateY(180deg);
}
.hexIn {
position: absolute;
width: 96%;
padding-bottom: 110.851%;
margin: 0 2%;
overflow: hidden;
visibility: hidden;
/*border: 8px solid red;*/
outline: 8px solid transparent;
transform: rotate3d(0, 0, 1, -60deg) skewY(30deg);
}
.hexInner {
position: absolute;
visibility: visible;
outline: 8px solid transparent;
background-color: #fff;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
box-sizing: border-box;
border: 8px solid red;
overflow: hidden;
transform: skewY(-30deg) rotate3d(0, 0, 1, 60deg);
}
.hexInner img {
left: -100%;
right: -100%;
width: auto;
height: 100%;
margin: 0 auto;
transform: rotate3d(0, 0, 0, 0deg);
filter: grayscale(100%);
transition: 4s;
}
.hexInner img:hover {
filter: grayscale(0%);
transition: 0s;
}
.hexInner p {
color: black;
text-align: center;
text-transform: uppercase;
font-weight: 300;
font-size: 2vw;
margin: 0;
}
.hexInIn {
border: 11px solid red;
visibility: visible;
background: transparent;
width: 96%;
padding-bottom: 114%;
transform: rotate3d(0, 0, 1,...
JavaScript
$(document).ready(function() {
"use strict";
$(".hexFront, .hexBack").click(function() {
$(".hexFront")
.css({ transform: "rotateY(0deg)", opacity: 1 })
.next()
.css({ transform: "rotateY(180deg)", opacity: 0 })
$(this)
.css({ transform: "rotateY(180deg)", opacity: 0 })
.next()
.css({ transform: "rotateY(0deg)", opacity: 1 })
.end().prev()
.css({ transform: "rotateY(0deg)", opacity: 1 });
});
});