首页 技术 正文
技术 2022年11月17日
0 收藏 670 点赞 5,009 浏览 2226 个字

3D变换和动画

  1. 建立3D空间,transform-style: preserve-3d
  2. perspective: 100px; 景深
  3. perspective-origin:center center -180px;  景深基点
  4. transform新增函数如下:
    • rotateX();
    • rotateY();
    • rotateZ();
    • translateZ();
    • scaleZ();
  5. 3d动画demo,只支持Webkit内核,可自行运行查看效果
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>无标题文档</title>
    <style>
    .wrap { width: 100px; height: 100px; -webkit-perspective: 200px; border: 5px solid pink; padding: 100px; margin: 200px auto 0; -webkit-transform: scale(2);}
    #box {width: 100px; height: 100px; position: relative; text-align: center; line-height: 100px; -webkit-transform-style: preserve-3d; transition: 3s; -webkit-transform-origin: center center -50px;}
    #box div {width: 100px; height: 100px; position: absolute; font-size: 50px; color: #FFF;}
    #box div:nth-of-type(1) {background-color: #F90; left: 0px; top: 0px;}
    #box div:nth-of-type(2) {background-color: #E08; left: 0px; top: -100px; -webkit-transform-origin: bottom; -webkit-transform: rotateX(90deg);}
    #box div:nth-of-type(3) {background-color: #A01; left: -100px; top: 0px; -webkit-transform-origin: right; -webkit-transform: rotateY(-90deg);}
    #box div:nth-of-type(4) {background-color: #CC0; left: 100px; top: 0px; -webkit-transform-origin: left; -webkit-transform: rotateY(90deg);}
    #box div:nth-of-type(5) {background-color: #D34; left: 0px; top: 100px; -webkit-transform-origin: top; -webkit-transform: rotateX(-90deg);}
    #box div:nth-of-type(6) {background-color: #000; left: 0px; top: 0px; -webkit-transform: translateZ(-100px) rotateX(180deg);}
    .wrap:hover #box{-webkit-transform: rotateX(360deg);}
    </style>
    <script>
    window.onload = function() {
    var oBox = document.getElementById("box");
    oBox.style.WebkitTransform = "rotateX(360deg)";
    addEnd(oBox, end1); function end1() {
    addEnd(oBox, end2);
    oBox.style.WebkitTransform = "rotateX(0deg)";
    } function end2() {
    addEnd(oBox, end3);
    oBox.style.WebkitTransform = "rotateY(360deg)";
    } function end3() {
    oBox.style.WebkitTransform = "rotateY(0deg)";
    } function addEnd(obj, fn) {
    obj.addEventListener('WebkitTransitionEnd', fn, false);
    obj.addEventListener('transitionend', fn, false);
    } function removeEnd(obj, fn) {
    obj.removeEventListener('WebkitTransitionEnd', fn, false);
    obj.removeEventListener('transitionend', fn, false);
    }
    };
    </script>
    </head>
    <body>
    <div class="wrap">
    <div id="box">
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
    <div>5</div>
    <div>6</div>
    </div>
    </div>
    </body>
    </html>
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,104
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,581
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,428
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,835
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,918