<style>
body{
}
.box {
position: relative;
margin: 100px auto;
/* 透视 */
perspective: 500px;
/* 动画的持续时间是2s */
transition: all 2s;
/* 让子元素保持3d空间环境
这句话必须写在最近的父元素中,写在body中将无效 */
transform-style: preserve-3d;
}
.box:hover{
transform: rotateY(-60deg);
}
div {
position: absolute;
width: 200px;
height: 200px;
background-color: aquamarine;
}
div:last-child {
background-color: red;
transform: rotateX(30deg);
}
</style>
</head>
<body>
<div class="box">
<div></div>
<div></div>
</div>
</body>
运行结果:
当鼠标经过时: