当前位置: 首页 > news >正文

css3之3D转换transform

css3之3D转换

  • 一.特点
  • 二.坐标系
  • 三.3D移动(translate3d)
    • 1.概念
    • 2.透视(perpective)(近大远小)(写在父盒子上)
  • 四.3D旋转(rotate3d)
    • 1.概念
    • 2.左手准则
    • 3.呈现(transfrom-style)(写父级盒子上)
    • 4.总结
  • 五.案例
    • 1.两面旋转
    • 2.导航栏
    • 3.旋转木马

一.特点

近大远小,后面看不见

二.坐标系

在这里插入图片描述

三.3D移动(translate3d)

1.概念

在这里插入图片描述

2.透视(perpective)(近大远小)(写在父盒子上)

在这里插入图片描述

四.3D旋转(rotate3d)

1.概念

在这里插入图片描述

2.左手准则

(1)沿着x轴旋转
在这里插入图片描述
(2)沿着y轴旋转
在这里插入图片描述

3.呈现(transfrom-style)(写父级盒子上)

在这里插入图片描述

4.总结

在这里插入图片描述

五.案例

1.两面旋转

在这里插入图片描述
在这里插入图片描述

<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>body {perspective: 350px;}.box {position: relative;width: 300px;height: 300px;margin: 100px auto;transition: all .4s;transform-style: preserve-3d;}.box:hover {transform: rotateY(180deg);}.front,.back {position: absolute;top: 0;left: 0;width: 100%;height: 100%;border-radius: 50%;font-size: 30px;color: #fff;text-align: center;line-height: 300px;}.front {background-color: pink;z-index: 1;}.back {background-color: purple;/*背对背旋转180deg,字不会镜像*/transform: rotateY(180deg);}</style>
</head><body><div class="box"><div class="front">黑马程序员</div><div class="back">pink老师等你</div></div>
</body></html>

2.导航栏

在这里插入图片描述

<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title>
</head>
<style>* {padding: 0;margin: 0;}ul {margin: 100px;}ul li {float: left;margin: 0 5px;width: 120px;height: 35px;list-style: none;perspective: 500px;}.box {position: relative;width: 100%;height: 100%;transform-style: preserve-3d;transition: all .4s;text-align: center;font-size: 16px;line-height: 35px;}.box:hover {transform: rotateX(90deg);}.front,.bottom {position: absolute;top: 0;left: 0;width: 100%;height: 100%;}.front {background-color: pink;z-index: 1;transform: translateZ(17.5px);}.bottom {background-color: purple;transform: translateY(17.5px) rotateX(-90deg);}
</style><body><ul><li><div class="box"><div class="front">黑马程序员</div><div class="bottom">pink老师等你</div></div></li></ul>
</body></html>

3.旋转木马

<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><style>body {perspective: 600px;}section {position: relative;width: 300px;height: 200px;margin: 250px auto;transform-style: preserve-3d;animation: rotate 10s linear infinite;}section div {position: absolute;top: 0;left: 0;width: 100%;height: 100%;background: url(001a3fe237b2c5e71eeca0a5ca44c68c.png) no-repeat;background-size: 300px 200px;}section:hover {animation-play-state: paused;}section div:nth-child(1) {transform: rotateY(60deg) translateZ(300px);}section div:nth-child(2) {transform: rotateY(120deg) translateZ(300px);}section div:nth-child(3) {transform: rotateY(180deg) translateZ(300px);}section div:nth-child(4) {transform: rotateY(240deg)translateZ(300px);}section div:nth-child(5) {transform: rotateY(300deg)translateZ(300px);}section div:nth-child(6) {transform: rotateY(360deg)translateZ(300px);}@keyframes rotate {0% {transform: rotateY(0);}100% {transform: rotateY(360deg);}}</style>
</head><body><section><div></div><div></div><div></div><div></div><div></div><div></div></section </body></html>
http://www.lryc.cn/news/331862.html

相关文章:

  • SpringBoot -- 外部化配置
  • 优酷动漫顶梁柱!神话大乱炖的修仙番为何火爆?
  • 每日一题:C语言经典例题之判断实数相等
  • 【算法每日一练]-数论(保姆级教程 篇1 埃氏筛,欧拉筛)
  • 【剑指offr--C/C++】JZ59 滑动窗口的最大值
  • RabbitMQ Tutorial
  • 如何对Webpack进行优化
  • nut-ui中的menu 菜单组件的二次封装
  • python笔记(11)序列
  • Rust egui(4) 增加自己的tab页面
  • 小组分享第二部分:Jsoup
  • C#(winform) 调用MATLAB函数
  • Kubernetes探索-Pod面试(补充)
  • 深入了解JUnit 5:新一代Java单元测试框架
  • 2024年清明节安装matlab 2024a
  • 关于PostgreSQL JDBC中的log输出是怎么回事?
  • 【科研笔记】知识星球不可选择内容爬虫
  • [技术闲聊]我对电路设计的理解(二)
  • 【Android、 kotlin】kotlin学习笔记
  • Debian 配置国内软件源
  • 选数(dfs,isprime)
  • RocketMQ(版本4.9.4)+RocketMQ_Dashbord环境搭建(生产者、消费者的前置环境搭建)
  • css隐藏溢出隐藏的滚动条
  • scss常用混入(mixin)、@inclue
  • 补代码随想录算法训练营第44天 | 完全背包、518. 零钱兑换 II 、377. 组合总和 Ⅳ
  • 【Linux】网络基础常识{OSI七层模型/ TCP/IP / 端口号 /各种协议}
  • python--面向对象编程和类的定义,对象的创建
  • nssm 工具把asp.net core mvc变成 windows服务,使用nginx反向代理访问
  • String Encryptor custom Bean not found with name ‘jasyptStringEncryptor‘...
  • FastAPI+React全栈开发14 FastAPI如何开发REST接口