alert('Hello World!')
console.log('Hello World!')
源码
<div class="content">
<div class="card">
<div class="card__side card__side--front">
<div class="card__cont">alert('Hello World!')</div>
</div>
<div class="card__side card__side--back">
<div class="card__cta">
<p>console.log('Hello World!')</p>
</div>
</div>
</div>
</div>
<style>
body {
background-image: linear-gradient(to bottom right, #ff9800, #ffa726);
}
.content{
height: 100vh;
color: white;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}
.card {
-webkit-perspective: 150rem;
perspective: 150rem;
height: 20rem;
width: 30rem;
position: relative;
}
.card__side {
height: 15rem;
transition: all 0.8s ease;
position: absolute;
top: 0;
left: 0;
margin: auto;
width: 30rem;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
border-radius: 3px;
overflow: hidden;
box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.4);
}
.card__side--front {
background-color: #1c1c1c;
}
.card__side--back {
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
background-color: #1c1c1c;
}
.card:hover .card__side--front {
-webkit-transform: rotateY(-180deg);
transform: rotateY(-180deg);
}
.card:hover .card__side--back {
-webkit-transform: rotateY(0deg);
transform: rotateY(0deg);
}
.card__cont {
height: 15rem;
background-color: #1c1c1c;
display: flex;
align-items: center;
justify-content: center;
}
.card__cta {
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
width: 90%;
color: white;
}
.card__cta p {
margin-left: 1rem;
}
.card__cta p>.space {
margin-left: 2rem;
}
</style>