3D盒子旋转
2018-03-22 17:49
246 查看
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>3D动画box</title>
<style type=text/css>
.warpper{position:fixed;top:30%;left:40%;perspective:1000px;}
.cube{
width:300px;height:300px;
transform-style:preserve-3d;/*设置3D环境*/
}
.side{
width:300px;height:300px;
background:rgba(255,121,134,0.6);
position:absolute;
font-size:60px;
color:#fff;
line-height:300px;
text-align:center;
border:1px solid red;
border-radius: 50%;
background:yellow;
}
.side_top{
width:300px;height:300px;
/*background:rgba(255,121,134,0.6);*/
background-image: url(img/01.png);
position:absolute;
font-size:60px;
color:#fff;
line-height:300px;
text-align:center;
background:yellow;
border:1px solid red;
/*border-radius: 50%;*/
opacity:0.9;
}
.side_bottom{
width:300px;height:300px;
/*background:rgba(255,121,134,0.6);*/
background-image: url(img/02.png);
position:absolute;
font-size:60px;
color:#fff;
line-height:300px;
text-align:center;
background:#dddd;
border:1px solid red;
/*border-radius: 50%;*/
opacity: 0.9;
}
.side_left{
width:300px;height:300px;
/*background:rgba(255,121,134,0.6);*/
background-image: url(img/03.png);
position:absolute;
font-size:60px;
color:#fff;
line-height:300px;
text-align:center;
border:1px solid red;
background:blue;
/*border-radius: 50%;*/
opacity: 0.9;
}
.side_right{
width:300px;height:300px;
/*background:rgba(255,121,134,0.6);*/
background-image: url(img/04.png);
position:absolute;
font-size:60px;
color:#fff;
line-height:300px;
text-align:center;
background:green;
border:1px solid red;
/*border-radius: 50%;*/
opacity: 0.9;
}
.side_back{
width:300px;height:300px;
/*background:rgba(255,121,134,0.6);*/
background-image: url(img/05.png);
position:absolute;
font-size:60px;
color:#fff;
background:red;
line-height:300px;
text-align:center;
background:black;
border:1px solid red;
/*border-radius: 50%;*/
opacity: 0.9;
}
.side_front{
width:300px;height:300px;
/*background:rgba(255,121,134,0.6);*/
background-image: url(img/06.png);
position:absolute;
font-size:60px;
color:#fff;
line-height:300px;
text-align:center;
border:1px solid red;
background:red;
/*border-radius: 50%;*/
opacity: 0.7;
}
.top{transform:rotateX(90deg) translateZ(150px);}
.bottom{transform:rotateX(-90deg) translateZ(150px);}
.left{transform:rotateY(-90deg) translateZ(150px);}
.right{transform:rotateY(90deg) translateZ(150px);}
.back{transform:rotateX(180deg) translateZ(150px);}
.front{transform:rotateY(0deg) translateZ(150px);}
</style>
</head>
<body>
<div class="warpper">
<div class="cube" id="cube">
<div class="top side_top">1</div>
<div class="bottom side_bottom">2</div>
<div class="left side_left">3</div>
<div class="right side_right">4</div>
<div class="back side_back">5</div>
<div class="front side_front">6</div>
</div>
</div>
<!--<script type="text/javascript" src="js/niannian-kuku.js"></script>-->
<script type="text/javascript">
var cubeDom = document.getElementById("cube");
var y = 0;
setInterval(function(){
if(y>360){
y=0;
}
y += 5;
cubeDom.style.transform = "rotateY("+y+"deg) rotateX("+y+"deg)";
//document.body.style.background = kuku.RandomColor();
//document.body.innerHTML = kuku.RandomNmb(1,11);
},100);
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>3D动画box</title>
<style type=text/css>
.warpper{position:fixed;top:30%;left:40%;perspective:1000px;}
.cube{
width:300px;height:300px;
transform-style:preserve-3d;/*设置3D环境*/
}
.side{
width:300px;height:300px;
background:rgba(255,121,134,0.6);
position:absolute;
font-size:60px;
color:#fff;
line-height:300px;
text-align:center;
border:1px solid red;
border-radius: 50%;
background:yellow;
}
.side_top{
width:300px;height:300px;
/*background:rgba(255,121,134,0.6);*/
background-image: url(img/01.png);
position:absolute;
font-size:60px;
color:#fff;
line-height:300px;
text-align:center;
background:yellow;
border:1px solid red;
/*border-radius: 50%;*/
opacity:0.9;
}
.side_bottom{
width:300px;height:300px;
/*background:rgba(255,121,134,0.6);*/
background-image: url(img/02.png);
position:absolute;
font-size:60px;
color:#fff;
line-height:300px;
text-align:center;
background:#dddd;
border:1px solid red;
/*border-radius: 50%;*/
opacity: 0.9;
}
.side_left{
width:300px;height:300px;
/*background:rgba(255,121,134,0.6);*/
background-image: url(img/03.png);
position:absolute;
font-size:60px;
color:#fff;
line-height:300px;
text-align:center;
border:1px solid red;
background:blue;
/*border-radius: 50%;*/
opacity: 0.9;
}
.side_right{
width:300px;height:300px;
/*background:rgba(255,121,134,0.6);*/
background-image: url(img/04.png);
position:absolute;
font-size:60px;
color:#fff;
line-height:300px;
text-align:center;
background:green;
border:1px solid red;
/*border-radius: 50%;*/
opacity: 0.9;
}
.side_back{
width:300px;height:300px;
/*background:rgba(255,121,134,0.6);*/
background-image: url(img/05.png);
position:absolute;
font-size:60px;
color:#fff;
background:red;
line-height:300px;
text-align:center;
background:black;
border:1px solid red;
/*border-radius: 50%;*/
opacity: 0.9;
}
.side_front{
width:300px;height:300px;
/*background:rgba(255,121,134,0.6);*/
background-image: url(img/06.png);
position:absolute;
font-size:60px;
color:#fff;
line-height:300px;
text-align:center;
border:1px solid red;
background:red;
/*border-radius: 50%;*/
opacity: 0.7;
}
.top{transform:rotateX(90deg) translateZ(150px);}
.bottom{transform:rotateX(-90deg) translateZ(150px);}
.left{transform:rotateY(-90deg) translateZ(150px);}
.right{transform:rotateY(90deg) translateZ(150px);}
.back{transform:rotateX(180deg) translateZ(150px);}
.front{transform:rotateY(0deg) translateZ(150px);}
</style>
</head>
<body>
<div class="warpper">
<div class="cube" id="cube">
<div class="top side_top">1</div>
<div class="bottom side_bottom">2</div>
<div class="left side_left">3</div>
<div class="right side_right">4</div>
<div class="back side_back">5</div>
<div class="front side_front">6</div>
</div>
</div>
<!--<script type="text/javascript" src="js/niannian-kuku.js"></script>-->
<script type="text/javascript">
var cubeDom = document.getElementById("cube");
var y = 0;
setInterval(function(){
if(y>360){
y=0;
}
y += 5;
cubeDom.style.transform = "rotateY("+y+"deg) rotateX("+y+"deg)";
//document.body.style.background = kuku.RandomColor();
//document.body.innerHTML = kuku.RandomNmb(1,11);
},100);
</script>
</body>
</html>
相关文章推荐
- 纯css样式实现盒子 3D 旋转、鼠标悬停效果
- 旋转的3D盒子
- 3d动画盒子旋转
- 3D盒子旋转
- iOS编程——Swift实现一个3D可旋转的立方体(可做菜单页)
- 基于CSS3的3D旋转效果
- WPF 3D:简单的Point3D和Vector3D动画创造一个旋转的正方体
- 2D、3D旋转矩阵
- UIView 的Transform。(旋转,缩放,3D旋转)
- [OpenGL ES 04]3D变换实践篇:平移,旋转,缩放
- 好玩的WPF第四弹:用Viewport2DVisual3D实现3D旋转效果
- JavaScrip实现3D旋转动态效果
- CSS图片3D旋转效果
- CSS3.0动画之hover---Y轴----3D旋转
- 【附源码】【Android 3D OpenGL】开发之二——旋转的三角形【MacroCheng原创】
- OpenGL3D图形、旋转、纹理、键盘移动、光照、滤波、透明(完整) 复制代码
- css动画属性实现3d效果立体盒子效果
- 实现3D旋转(源码)
- CATransform3D 矩阵变换之立方体旋转实现细节