Rotacionando Cards
Publicado em 27-11-2024
HTML:
<div class="card">
<div class="card-inner">
<div class="card-front">
<div>
<h2>Parte da frente</h2>
<p>Passe o mouse para ver a parte de trás.</p>
</div>
</div>
<div class="card-back">
<div>
<h2>Parte de trás</h2>
<p>Surpresa! Essa é a parte de trás.</p>
</div>
</div>
</div>
</div>
CSS:
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: linear-gradient(120deg, #1e3c72, #2a5298);
font-family: Arial, sans-serif;
}
.card {
width: 300px;
height: 200px;
perspective: 1000px;
}
.card-inner {
position: relative;
width: 100%;
height: 100%;
transform-style: preserve-3d;
transition: transform 0.8s;
}
.card:hover .card-inner {
transform: rotateY(180deg);
}
.card-front,
.card-back {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
display: flex;
padding: 20px;
align-items: center;
border-radius: 10px;
box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
}
.card-front {
background: #ffffff;
color: #333;
}
.card-back {
background: #f76c6c;
color: #ffffff;
transform: rotateY(180deg);
}
h2 {
font-size: 1.5em;
}
p {
margin: 10px 0 0;
font-size: 1em;
}