zoukankan      html  css  js  c++  java
  • CSS 动画 : 创建 3D 立方体

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>3D Sunstance (Substantial) cube</title>
        <style>
          * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
          }
          body {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            width: 100%;
            height: 100vh;
            background: #606060;
            /* 视角,必须开视角才可以看到旋转位移的3D属性 */
            perspective: 500px;
            overflow: hidden;
          }
          .main {
            position: relative;
            width: 200px;
            height: 200px;
            margin: 0 auto;
            margin-top: 200px;
            /* 
              必须声明 transform-style:preserve-3d 才可以展示3D属性的变化
              因为其默认 2d ,transform-style:flat 
            */
            transform-style:preserve-3d; 
              animation:run 10s infinite;
          }
          .box {
            width: 200px;
            height: 200px;
            background-color: #f9bf3b;
            display: grid;
            place-items: center;
            font-size: 50px;
            position: absolute;
            opacity: 0.6;
          }
          .box:first-child {
            transform: rotateY(90deg) translateZ(100px);
          }
          .box:nth-child(2) {
            transform: rotateY(-90deg) translateZ(100px);
            background-color: #8e44ad;
          }
          .box:nth-child(3) {
            transform: rotateX(90deg) translateZ(100px);
            background-color: #22a7f0;
          }
          .box:nth-child(4) {
            transform: rotateX(-90deg) translateZ(100px);
            background-color: #ffa27b;
          }
          .box:nth-child(5) {
            transform: rotateX(180deg) translateZ(100px);
            background-color: #e74c3c;
            z-index: -1;
          }
          .box:nth-child(6) {
            transform: rotateY(0deg) translateZ(100px);
            background-color: #ecf0f1;
          }
          @keyframes run {
            0% {
              transform: rotateY(0);
            }
            10% {
              transform: rotateY(180deg);
            }
            20% {
              transform: rotateX(180deg);
              /* transform: rotateY(180deg); */
            }
          }
        </style>
      </head>
      <body>
        <div class="main">
          <div class="box"></div>
          <div class="box"></div>
          <div class="box"></div>
          <div class="box"></div>
          <div class="box"></div>
          <div class="box"></div>
        </div>
      </body>
    </html>
  • 相关阅读:
    SqlServer中插入无时间的日期
    IEnumerable的扩展方法
    JQuery插件之Autocomplete
    Visual Studio2010 即时生成序列图
    SQLSERVER系统表应用之基于Table生成存储过程参数列表
    格式化代码之自动加Region
    SQLSERVER2008使用CTE转换string到Table
    SQLSERVER使用CLR Stored Procedure导出数据到Excel
    SQLSERVER中找出拙劣的约束,索引,外键
    SQLSERVER2008中CTE的Split与CLR的性能比较
  • 原文地址:https://www.cnblogs.com/500m/p/13529000.html
Copyright © 2011-2022 走看看