<!-- <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测试文档</title>
<style>
.box {
position: relative;
width: 400px;
height: 400px;
border-radius: 200px;
margin: 10px auto;
box-shadow: 0px 0px 15px #df5000;
transition: all 2s;
transform-style: preserve-3d;
}
img {
display: block;
position: absolute;
width: 100%;
height: 100%;
border-radius: 200px;
}
.box img:nth-child(1) {
/* transform: translateZ(1px); */
transform: translateZ(1px);
}
.box img:nth-child(2) {
/*因为文字在旋转前先翻过去,不然转的字体就是反的*/
transform: rotateY(180deg);
}
.box:hover {
transform: rotateY(180deg);
}
</style>
</head>
<body>
<p>看图背古诗</p>
<div class="box">
<img src="https://zk.yxycf.top/resource/bg/2.png">
<img src="https://zk.yxycf.top/resource/bg/6.png">
</div>
</body>
</html>
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<style>
boby {
/*视图最好大于元素的高度的一半,不然就会出现前面所说的问题,有可能会超过视距的长度*/
perspective: 600px;
}
.overturn {
position: relative;
width: 300px;
height: 300px;
margin: 100px auto;
transition: all 2s;
/* 让背面的盒子保留立体空间 给父级添加的 */
transform-style: preserve-3d;
cursor: pointer;
user-select: none;
}
.front,
.reverse {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 50%;
font-size: 30px;
color: #fff;
text-align: center;
line-height: 300px;
}
.front {
background: #00fff7;
transform: translateZ(1px);
}
.reverse {
background: #c78ed0;
/* 像手机一样,背靠背旋转 */
transform: rotateY(180deg);
}
.overturn:hover {
transform: rotateY(180deg);
}
</style>
</head>
<body>
<div class="overturn">
<div class="front">正面-111</div>
<div class="reverse">反面-222</div>
</div>
</body>
</html>
css 翻转
最新推荐文章于 2024-05-22 11:43:55 发布