翻转卡片的CSS实现
.card-container {
width: 300px;
height: 400px;
position: relative;
-webkit-perspective: 1000px;
}
.cover,
.back {
width: 100%;
height: 100%;
position: absolute;
display: flex;
justify-content: center;
align-items: center;
backface-visibility: hidden;
transition: transform 0.5s ease-in-out;
font-size: 2rem;
font-family: Helvetica;
border-radius: 0.8rem;
color: #fff;
box-shadow: 0 0.2rem 0.5rem rgba(0, 0, 0, 0.18);
text-shadow: 0 0.3rem 0.5rem rgba(0, 0, 0, 0.2);
}
.cover {
background: #373b44; /* fallback for old browsers */
background: -webkit-linear-gradient(
to left,
#4286f4,
#373b44
); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(
to left,
#4286f4,
#373b44
); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
transform: rotatey(0deg);
}
.back {
background: #fffbd5; /* fallback for old browsers */
background: -webkit-linear-gradient(
to left,
#b20a2c,
#fffbd5
); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(
to left,
#b20a2c,
#fffbd5
); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
transform: rotatey(-180deg);
}
.card-container:hover .cover {
transform: rotatey(180deg);
}
.card-container:hover .back {
transform: rotatey(0deg);
}