这个是3D旋转的进阶版,是一个类似与骰子的正方体。这个版本只有秒数的个位数,还没有写整个钟表,下面那个版本好好想想该怎么写

  1. 这个效果需要用到transform-style: preserve-3d
  2. 利用transform: rotateX, rotateY, rotateZ来定义物体转动轴,实现3D旋转
  3. 给一个正方体设置6个面,每个面都设置旋转基面,并且直接先朝各个方向转90度,有一个面要注意,就是和最前面的那个面的对面,不用转,但是要用transform: translateZ()来让这个面沿着Z轴移动到后面,同时要让这个面上的数字或者文字还要translateX(180deg),这样就能让背面的那个字转过来是正着的,否则它在背面是正的时候再转过来就变成倒着的了
  4. 为了让这个骰子有点看上去是有点往右倾斜,就想到给它rotateY(10deg),但是直接加载box上会有问题,为了让它转动,已经加过一次transform:rotateX,再加一个transform会把这个覆盖,所以想到了,在这个box外面再加一个outerbox,让outerbox往右倾斜就可以。
  5. 在转动一次之后,要让即将转过来的那个面的数字变成下一秒的个位数
  6. 复习一下如何取到一个2位数的个位数字和十位数字。个位=x- parseInt(x/10)*10;十位数字=parseInt(x/10);
<style>
#wrap{
margin: 70px auto;
width: 100px;
height: 100px;
padding: 100px;
perspective: 900px; //注意要把perspective写最外面
}
#outerbox{
width: 100px;
height: 100px;
transform-origin: center center;
transform-style: preserve-3d; //为了让骰子总是向左斜10度,要在外面再加一层,并让它具有3d样式
transform: rotateY(10deg);
}
#box{
width: 100px;
height: 100px;
transform-style: preserve-3d;
% -49px;
,1.46);
position: relative;
}
#box div{
width: 98px;
height: 98px;
border: 1px solid black;
font: 50px/100px arial;
text-align: center;
position: absolute;
opacity: 0.4;
}
#box div:nth-of-type(2){
top: -100px;
transform-origin: bottom;
transform: rotateX(90deg);
}
#box div:nth-of-type(1){
}
#box div:nth-of-type(4){
top: 100px;
transform-origin: top;
transform: rotateX(-90deg);
}
#box div:nth-of-type(3){
transform: translateZ(-100px) rotateX(180deg);
}
#box div:nth-of-type(5){
left: 100px;
transform-origin: left;
transform: rotateY(90deg);
}
#box div:nth-of-type(6){
left: -100px;
transform-origin: right;
transform: rotateY(-90deg);
}
</style>
<script>
window.onload = function(){
var oBox = document.getElementById('box');
;
;
var aDiv = oBox.getElementsByTagName('div');
; i<aDiv.length; i++) {
aDiv[i].index = i;
}
 
function rote(){
var oDate = new Date();
var iSec = oDate.getSeconds();
;
);
oBox.style.transform = 'rotateX('+angle+'deg)';
;
){
;
}
document.title=iSecS;
aDiv[Index].innerHTML = iSecS;
Index++;
}
rote();
);
};
</script>
</head>
<body>
<div id="wrap">
<div id="outerbox">
<div id="box">
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</div>
</div>
</div>
</body>

最新文章

  1. (转)我如何利用前端技术得到 XXOO 网站的 VIP
  2. 史航416第11次作业&amp;总结
  3. Django,数据模型创建之数据库API参考(转载)
  4. JAVA+PHP+阿里云组件纯手工实现POP、SMTP、IMAP开发邮件服务器(二)
  5. 批量导出表数据到CSV文件
  6. 【原版的:参赛作品】窥秘懒---android打开下拉手势刷新时代
  7. 【转载】2015 Objective-C 三大新特性 | 干货
  8. python3 文件操作练习 r+ w+ a+ 的理解
  9. [Swift]LeetCode1013. 将数组分成和相等的三个部分 | Partition Array Into Three Parts With Equal Sum
  10. java 形式参数和实际参数的区别
  11. Linux基础第六课——grep|awk|sort|uniq
  12. Centos7更改yum镜像源
  13. 读取web.config和app.config配置文件
  14. 避免resolv.conf设置被覆盖
  15. JAVA 传递
  16. eclipse使用ctrl+shift+F格式化代码失效
  17. c++MFC工程修改在共享DLL中使用MFC为使用标准Windows库的解决办法
  18. spring boot2 基于百度云apiface实现人脸检测与认证2
  19. BestCoder Round #93
  20. 微信小程序-scroll-view组件

热门文章

  1. Python中 filter | map | reduce | lambda的用法
  2. Tomcat下安装solr6.x
  3. JQ判断屏幕宽度
  4. 超实用的JavaScript技巧及最佳实践
  5. 使用OpenFileDialog会更改默认程序目录
  6. ets查询:查询表中的具体一列的所有值
  7. offset client scroll
  8. Qt开发环境中使用报表控件FastReport遇到的一些问题(二)
  9. Windows 下字节转换
  10. Interproscan, xml文件转化为tsv