CSS变形与动画(二):perspctive透视效果 与 preserve-3d 3d效果(奥运五环例子)

文章目录

    • [perspective 3d透视效果](#perspective 3d透视效果)
    • [preserve-3d 3d嵌套效果](#preserve-3d 3d嵌套效果)
      • [例子 奥运五环](#例子 奥运五环)
    • [backface-visibility 背面效果](#backface-visibility 背面效果)

perspective 3d透视效果

perspective 指定了观察者与 z=0 平面的距离,使具有三维位置变换的元素产生透视效果。z>0 的三维元素比正常大,而 z<0 时则比正常小,大小程度由该属性的值决定。

作用于在父级上。

preserve-3d 3d嵌套效果

相互可以视觉上 插入 和 覆盖

transform-style: preserve-3d; 也是用在父级

例子 奥运五环

通过每个环细微的旋转角度实现。

主要看各环之间的覆盖关系,这就是3d嵌套的效果。

css 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .mb{
            background: pink;
            height:600px;
            display: flex;
            justify-content: center;
        }
        .m{
            padding-top: 200px;
            width:360px;
            height: 200px;
            display: flex;
            flex-wrap: wrap;
            transform-style: preserve-3d;
        }
        .l{
            margin: 2px;
        }
        .l:nth-child(1){
            width:100px;
            height: 100px;
            border:7px solid blue;
            border-radius: 100%;
            transform: rotateX(-1deg) rotateY(-2deg);

        }
        .l:nth-child(2){
            width:100px;
            height: 100px;
            border:7px solid black;
            border-radius: 100%;
            transform: rotateX(-1deg) rotateY(-2deg);
        }
        .l:nth-child(3){
            width:100px;
            height: 100px;
            border:7px solid red;
            border-radius: 100%;
            transform: rotateX(-3deg) rotateY(-3deg);
        }
        .l:nth-child(4){
            width:100px;
            height: 100px;
            border:7px solid yellow;
            border-radius: 100%;
            position: relative;
            left:56px;
            bottom: 60px;
            transform: rotateX(0deg) rotateY(2deg);
        }
        .l:nth-child(5){
            width:100px;
            height: 100px;
            border:7px solid green;
            border-radius: 100%;
             position: relative;
            left:56px;
            bottom: 60px;
            transform: rotateX(2deg) rotateY(4deg);
        }
    </style>
</head>
<body>
    <div class="mb">
        <div class="m">
            <div class="l"></div>
            <div class="l"></div>
            <div class="l"></div>
            <div class="l"></div>
            <div class="l"></div>
        </div>
    </div>
</body>
</html>

backface-visibility 背面效果

backface-visibility: hidden; 背面不可见

相关推荐
码艺-Alimjan5 小时前
横向滚动组件纯用 CSS,丝滑鼠标滚动不许js
javascript·css·计算机外设
砚凝霜8 小时前
软考网络工程师|案例分析:Eth‑Trunk 链路聚合、iStack 堆叠、CSS 集群核心考点总结
前端·css·网络
杀生丸学AI11 小时前
【三维重建】QuerySplat:在 3DGS 预测中解耦几何与外观表征
人工智能·3d·三维重建·扩散模型·高斯泼溅·空间智能·室内重建
杀生丸学AI1 天前
【世界模型】Lyra 2.0:可探索的生成式3D世界(NVIDIA)
人工智能·深度学习·3d·数据挖掘·transformer·世界模型·高斯泼溅
毕安格 - BimAngle1 天前
国家电网 GIM 格式模型一键输出 3D Tiles (for Cesium) 和 glTF/glb 更新时间:2026-08-18
3d·gis·cesium·gltf·glb·3d tiles·gim
breeze jiang1 天前
CSS 三栏布局怎么写:Flex、Grid 完整方案与 BFC 区别
前端·css
何时梦醒1 天前
CSS 三栏布局与 BFC 深度解析:Float、Flex、Grid 三种方案一网打尽
前端·css·面试
烬羽1 天前
CSS 三栏布局:`margin-left: -100%` 凭什么把侧栏「拽」回上一行?彻底搞懂负 margin
css·面试·前端框架
BreezeJiang1 天前
写了 display:flex,为什么三栏布局还没完成?
前端·css
用户938515635072 天前
TypeScript 高级类型 + CSS 三列布局:从类型体操到样式工程的进阶之路
css·面试·typescript