首页 技术 正文
技术 2022年11月18日
0 收藏 308 点赞 3,065 浏览 2942 个字

接着上一篇博客的内容顺藤摸瓜往下想,既然stage有景深这个概念,可以表达3D场景,那么这个stage就可以呈现立体几何咯,于是自己写了个Cubic Demo

一个正方体有6个面,我们把一个正方体平铺开来就是一个十字的形状,然后变换每一面的角度把正方体“折叠”起来!

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<title>Cube</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
} li{
list-style: none;
} .wrapper{
width:200px;
height: 200px;
border: 1px solid #f60;
margin: 0 auto;
padding: 100px;
margin-top: 100px;
-webkit-perspective:800px;
}
.cube{
width: 200px;
height: 200px;
position: relative;
-webkit-transform-style:preserve-3d;
transition:1s all; }
.cube li{
width: 200px;
height: 200px;
position: absolute;
text-align: center;
line-height: 200px;
color: #fff;
font-size: 30px;
}
.cube li:nth-of-type(1){
background: red;
top: -200px;
left: 0;
-webkit-transform-origin: bottom;
-webkit-transform: translateZ(100px) rotateX(90deg);
}
.cube li:nth-of-type(2){
background: green;
top: 0;
left: -200px;
-webkit-transform-origin: right;
-webkit-transform: translateZ(100px) rotateY(-90deg);
}
.cube li:nth-of-type(3){
background: blue;
top: 0;
left: 0;
-webkit-transform: translateZ(100px);
}
.cube li:nth-of-type(4){
background: yellow;
top: 0;
left: 200px;
-webkit-transform-origin: left;
-webkit-transform: translateZ(100px) rotateY(90deg);
}
.cube li:nth-of-type(5){
background: purple;
top: 200px;
left: 0;
-webkit-transform-origin: top;
-webkit-transform: translateZ(100px) rotateX(-90deg);
}
.cube li:nth-of-type(6){
background: orange;
top: 0;
left: 0;
-webkit-transform: translateZ(-100px) rotateX(180deg);
} .wrapper:hover .cube{
-webkit-transform:rotateX(180deg);
}
</style>
</head>
<body>
<div class="wrapper">
<ul class="cube">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
</ul>
</div>
</body>
</html>

也可以把另外两个侧面去掉,只留4个面。

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
<title>Cube2</title>
<style type="text/css">
*{
margin: 0;
padding: 0;
} li{
list-style: none;
} .wrapper{
width:200px;
height: 200px;
border: 1px solid #f60;
margin: 0 auto;
padding: 100px;
margin-top: 100px;
-webkit-perspective:800px;
}
.cube{
width: 200px;
height: 200px;
position: relative;
-webkit-transform-style:preserve-3d;
transition:1s all;
-webkit-transform:translateZ(-100px) rotate(0deg);
}
.cube li{
width: 200px;
height: 200px;
position: absolute;
text-align: center;
line-height: 200px;
color: #fff;
font-size: 30px;
}
.cube li:nth-of-type(1){
background: red;
-webkit-transform:translateZ(100px);
}
.cube li:nth-of-type(2){
background: green;
-webkit-transform-origin:top;
-webkit-transform:translateZ(-100px) rotateX(90deg);
}
.cube li:nth-of-type(3){
background: blue;
-webkit-transform:translateZ(-100px) rotateX(180deg);
}
.cube li:nth-of-type(4){
background: yellow;
-webkit-transform-origin:bottom;
-webkit-transform:translateZ(-100px) rotateX(-90deg);
} .wrapper:hover .cube{
-webkit-transform: translateZ(-100px) rotateX(270deg);
}
</style>
</head>
<body>
<div class="wrapper">
<ul class="cube">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
</body>
</html>
上一篇: es6三个点运算符
下一篇: quartz定时任务-job
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,954
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,479
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,291
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,108
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,740
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,774