<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="viewport" content="initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0">
<title>CSS3 3D旋转立方体</title>
<style>
body{
margin:0;
padding:0;
}
.cube{
width: 800px;
height: 400px;
-webkit-perspective: 1000px;
margin:200px auto 0 auto;
}
.ant{
width: 100%;
height: 100%;
-webkit-transform-style: preserve-3d;
-webkit-transform: translate3d(0,0,-200px) rotateY(0deg);
-webkit-animation:xuanzhuan 5s infinite linear;
}
.face{
width: 100%;
height: 100%;
position: absolute;
border:1px solid;
-webkit-backface-visibility: visible;
overflow: hidden;
z-index: 10;
text-align: center;
font-size: 50px;
}
.face span {
height: 100%;
display: inline-block;
vertical-align: middle;
}
.face-right{
-webkit-transform: translate3d(400px , 0 , 0px) rotateY(-90deg);
}
.face-left{
-webkit-transform: translate3d(-400px , 0 , 0px) rotateY(90deg);
}
.face-in{
-webkit-transform: translate3d(0px , 0 , -400px) rotateY(0deg);
}
.face-out{
-webkit-transform: translate3d(0px , 0 , 400px) rotateY(180deg);
}
.face-bottom{
height: 800px;
-webkit-transform: translate3d(0px , 0px , 0px) rotateX(90deg);
}
.face-top{
height: 800px;
-webkit-transform: translate3d(0px , -400px , 0px) rotateX(-90deg);
}
@-webkit-keyframes xuanzhuan{
from{
-webkit-transform: translate3d(0,0,-200px) rotateY(0deg);
}
to{
-webkit-transform: translate3d(0,0,-200px) rotateY(360deg);
}
}
</style>
</head>
<body>
<div class="cube">
<div class="ant">
<div class="face face-right"><span></span>1</div>
<div class="face face-left"><span></span>2</div>
<div class="face face-in"><span></span>3</div>
<div class="face face-out"><span></span>4</div>
<div class="face face-bottom"><span></span>5</div>
<div class="face face-top"><span></span>6</div>
</div>
</div>
</body>
</html>

【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步