What is a flip card effect?
A flip card effect is an animation that flips a card from front to back (or vice versa) when the user clicks on it.
How can I create this effect in my memory campaign?
Here are the steps to add a flip card effect using CSS and JavaScript:
Step 1: Use the Following CSS to style the cards and create the flip effect
Add the following CSS code in the CSS tab of the look and feel step.
/* Flip cards */
.card {
perspective: 1000px;
cursor: pointer;
box-shadow: none !important;
}
.content_img {
transform-style: preserve-3d;
transition: transform 0.5s;
}
.content_photo::before {
transform: rotateY(0deg);
}
.card.flipped .content_photo::before {
transform: rotateY(180deg);
}
.card.flipped .content_img {
transform: rotateY(180deg);
}
.card.flipped .content_photo img {
transform: rotateY(180deg);
}
Step 2: Add JavaScript to manipulate the cards
Finally, use JavaScript code to add the logic that flips the cards when they are clicked:
In the tag library, you can create a new "Tag name":
flip_cards_effect
.
Then, add the JavaScript code in the body section.
<script>
document.querySelectorAll('.card').forEach(card => {
card.addEventListener('click', function() {
this.classList.toggle('flipped');
});
});
</script>
By following these steps, you can easily add a flip card effect to your memory game, enhancing the user experience with a visually appealing animation.