You are on page 1of 2

<!

DOCTYPE html>
<html>
<head>
<title>Card Animations</title>
<style>
body {
background-color: black;
}

.card {
width: 200px;
height: 100px;
border-radius: 15px;
background-color: white;
margin: 10px;
}

.hidden-card {
opacity: 0;
}

.card:hover .hidden-card {
opacity: 1;
animation: tild 1s linear infinite;
}

@keyframes tild {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
</style>
</head>
<body>
<div class="card">
<h2>Card 1</h2>
</div>
<div class="card">
<h2>Card 2</h2>
</div>
<div class="card hidden-card">
<h2>Card 3</h2>
</div>

<script>
const cards = document.querySelectorAll(".card");

for (const card of cards) {


card.addEventListener("mouseenter", function() {
const hiddenCard = this.querySelector(".hidden-card");
hiddenCard.classList.add("visible");
});

card.addEventListener("mouseleave", function() {
const hiddenCard = this.querySelector(".hidden-card");
hiddenCard.classList.remove("visible");
});
}
</script>
</body>
</html>

You might also like