<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
body{
background: yellow;
}
/*最外层样式*/
.wrap{
width: 200px;
height 200px;
margin: 200px auto;
/*border: 1px solid red;*/
/*background: red;*/
position: relative;
}
/*包裹所有容器的样式*/
.cube{
width: 200px;
height: 200px;
/*perspective: 500px;*/
/*保持3D效果*/
margin: 0 auto;
transform-style: preserve-3d;
transform: rotateX(-30deg) rotateY(-80deg);
animation: rotate linear 10s infinite;
}
@-webkit-keyframes rotate{
from{
transform: rotateX(0deg) rotateY(0deg);
}
to{
transform: rotateX(360deg) rotateY(360deg);
}
}
.cube div{
position: absolute;
width: 200px;
height: 200px;
/*opacity: 0.8;*/
/*0.4秒*/
transition: all .4;
}
/*定义所有图片的样式*/
.pic{
width: 200px;
height: 200px;
}
CSS实现简单的3D旋转魔方
最新推荐文章于 2022-05-25 10:33:44 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)