<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body {
perspective: 500px;
}
.contain {
position: relative;
width: 300px;
height: 300px;
margin: 100px auto;
}
.box {
width: 300px;
height: 300px;
border-radius: 50%;
transition: all 0.5s;
transform-style: preserve-3d;
}
.box .front,
.box .back {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 50%;
font-size: 50px;
text-align: center;
line-height: 300px;
color: #fff;
}
.box .front {
background-color: pink;
z-index: 1;
/* 翻转后隐藏 */
backface-visibility: hidden;
}
.box .back {
background-color: blueviolet;
/* 后面的div旋转180度,保证文字显示正确 */
transform: rotateY(180deg);
}
.contain:hover .box {
transform: rotateY(180deg);
}
</style>
</head>
<body>
<div class="contain">
<div class="box">
<div class="front">日出又日落</div>
<div class="back">深处再深处</div>
</div>
</div>
</body>
</html>
鼠标放上之后,圆圈旋转: