Why does this only work the first time?
<!DOCTYPE html> <html> <head> <title>Page Title</title> <style> .scene { width: 200px; height: 260px; perspective: 600px; } #card { width: 100%; height: 100%; text-align: center; font-size: 2em; color: white; background: radial-gradient(cyan, teal); position: relative; backface-visibility: hidden; z-index: 2; border-radius: 5%; } .card { animation: flip .7s linear; animation-fill-mode: forwards; } @keyframes flip{ 0% {transform: translatez(0) rotatey(0);} 50% {transform: translatez(200px) rotatey(-90deg);} 100% {transform: translatez(0) rotatey(-180deg);} } .card3 { animation: flip3 .7s linear; animation-fill-mode: forwards; } @keyframes flip3{ 100% {transform: translatez(0) rotatey(0);} 50% {transform: translatez(200px) rotatey(-90deg);} 0% {transform: translatez(0) rotatey(-180deg);} } #front { position: relative; top: 38%; cursor: default; } #card2 { width: 100%; height: 100%; text-align: center; font-size: 3em; color: white; background: radial-gradient(red, maroon); position: relative; top: -100%; z-index: 1; border-radius: 5%; backface-visibility: hidden; } .card2 { animation: flip2 .7s linear; animation-fill-mode: forwards; } @keyframes flip2{ 0% {transform: translatez(0) rotatey(180deg);} 50% {transform: translatez(200px) rotatey(90deg);} 100% {transform: translatez(0) rotatey(0);} } .card4 { animation: flip4 .7s linear; animation-fill-mode: forwards; } @keyframes flip4{ 100% {transform: translatez(0) rotatey(180deg);} 50% {transform: translatez(200px) rotatey(90deg);} 0% {transform: translatez(0) rotatey(0);} } </style> </head> <body> <div class="scene"> <div id='card' onclick='flip(), flip2()'> </div> <div id='card2' onclick='flip3(), flip4()'> <div id='front'>Contessa</div> </div>