首页 > web前端 > css教程 > 正文

css 3d 基础知识

高洛峰
发布: 2017-02-11 11:42:41
原创
1170人浏览过

css3d 总结

3d transform (3d变形)(rotate skew scale translate)

基础知识

perspective (视距,景深) perspective-origin (视点)
transfrom

(1) 坐标 x y z

(2) 变形 基点位置 transform-origin
(3)transfrom-style:preserve-3d

立即学习前端免费学习笔记(深入)”;

3D旋转图片相册

css 3d    基础知识
3d transform (3d变形)(rotate skew scale translate)

基础知识

perspective (视距,景深) perspective-origin (视点)
transfrom

(1) 坐标 x y z

(2) 变形 基点位置 transform-origin
(3)transfrom-style:preserve-3d

立即学习前端免费学习笔记(深入)”;

3D旋转图片相册

css 3d 基础知识
它就用到了一个比较简单的坐标y 轴旋转那咱们看一下他的代码

html的代码:
  <p class="kj" id="kj">
    <p class="mian">@@##@@</p>
    <p class="mian">@@##@@</p>
    <p class="mian">@@##@@</p>
    <p class="mian">@@##@@</p>
    <p class="mian">@@##@@</p>
    <p class="mian">@@##@@</p>
    <p class="mian">@@##@@</p>
    <p class="mian">@@##@@</p>
    <p class="mian">@@##@@</p>
  </p>
登录后复制

首先要建九个盒子放九张图片,这个很容易理解的。

css的代码



          body{
            background: #6daf39;(背景加了个颜色 主要是好看)
          }
          .xj{
          perspective:600px;(这是井深)
          }
          .kj{
          transition: 1s;(运动时间)
          transform-style:preserve-3d;(实现3d效果 当然这是非常重的)
          width:200px;
          height: 300px;
          margin:80px auto;
          position: relative;
          transform: rotateY(0deg) rotateX(0deg) translateZ(-275px);
          transform-origin: center center -275px;
          }

      .mian{
        position:absolute;
        font-size: 50px;
        color:#fff;
        text-align: center;
        line-height: 300px;
      }
      .mian:nth-child(1){
        width:200px;
        height: 300px;
        background: #ff2223;
        transform: rotateY(0deg)translateZ(275px);
      }
      .mian:nth-child(2){
        width:200px;
        height: 300px;
        background: #ff2223;
        transform: rotateY(40deg)translateZ(275px);
      }
      .mian:nth-child(3){
        width:200px;
        height: 300px;
        background: #ff2223;
        transform: rotateY(80deg)translateZ(275px);
      }
      .mian:nth-child(4){
        width:200px;
        height: 300px;
        background: #ff2223;
        transform: rotateY(120deg)translateZ(275px);
      }
      .mian:nth-child(5){
        width:200px;
        height: 300px;
        background: #ff2223;
        transform: rotateY(160deg)translateZ(275px);
      }
      .mian:nth-child(6){
        width:200px;
        height: 300px;
        background: #ff2223;
        transform: rotateY(200deg)translateZ(275px);
      }
      .mian:nth-child(7){
        width:200px;
        height: 300px;
        background: #ff2223;
        transform: rotateY(240deg)translateZ(275px);
      }
      .mian:nth-child(8){
        width:200px;
        height: 300px;
        background: #ff2223;
        transform: rotateY(280deg)translateZ(275px);
      }
      .mian:nth-child(9){
        width:200px;
        height: 300px;
        background: #ff2223;
        transform: rotateY(320deg)translateZ(275px);
      }
登录后复制

css就到这里,很简单的;

js的代码
    kj.onclick=function () {
      cishu++;
      var jiaodu=40*cishu;


      kj.style.transform="rotateY("+jiaodu+"deg)translateZ(-275px)"
    }
登录后复制

(kj)就是3d空间,点击kj要是一种效果,就要有一种方法或步骤;
3d空间样式rotateY(这就是上下轴旋转)translateZ(Z这就是3d立体字轴;让3d空间后移275px找到轴心位置)

更多css 3d  基础知识 相关文章请关注PHP中文网!

css 3d 基础知识 css 3d 基础知识 css 3d 基础知识 css 3d 基础知识 css 3d 基础知识 css 3d 基础知识 css 3d 基础知识 css 3d 基础知识 css 3d 基础知识
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
相关标签:
css
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号