直接贴代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<style>
.box {
width: 300px;
height: 300px;
color: #fff;
position: relative;
transition: 2s ease-in-out;
}
.front {
width: 300px;
height: 300px;
position: absolute;
transition: 2s ease-in-out;
background-color: pink;
}
.back {
width: 300px;
height: 300px;
background-color: #000;
position: absolute;
backface-visibility:hidden;
transform: rotateY(180deg);
transition: 2s ease-in-out;
}
.box:hover .front{
transform: rotateY(180deg);
}
.box:hover .back{
transform: rotateY(360deg);
}
</style>
<body>
<div class="box">
<div class="front">我是翻转前</div>
<div class="back">我是翻转后</div>
</div>
</body>
</html>