.container2 {
  margin: 20px;
  width: 500px;
  height: 500px;
  perspective: 1000px;
}

.card {
  transition: transform 0.4s;
  transform-style: preserve-3d;
  cursor: pointer;
}

.front, .back {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  backface-visibility: hidden;
}

.front {
  border: 2px solid black;
  background: url("http://placehold.it/250x250");
}

.front:hover {
  bottom: 2px;
  left: 2px;
  box-shadow: 0px 0px 20px 1px #000;
}

.back {
  border: 2px solid black;
  background: url("http://placehold.it/100x100");
  transform: rotateY(180deg);
}

.back:hover {
  bottom: 2px;
  right: 2px;
  box-shadow: 0px 0px 20px 1px #000;
}

