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; 背面不可见

相关推荐
拜无忧10 小时前
纯css,顺时针3d旋转基座(摩天轮效应)
前端·css
科研面壁者15 小时前
SPSS——绘制“简单分布散点图”,“矩阵散点图”,“简单点图”,“重叠散点图”,“3D分布散点图”
3d·信息可视化·矩阵·数据分析·spss·科研绘图
i_am_a_div_日积月累_16 小时前
css排除样式:not:has
前端·css
laoliu199617 小时前
使用VScode+AI大模型驱动Blender建模
3d·ai·blender
咬人喵喵17 小时前
网页开发的“三剑客”:HTML、CSS 和 JavaScript
javascript·css·html
BUG创建者18 小时前
thee.js完成线上展厅demo
开发语言·前端·javascript·css·html·css3·three.js
我有一棵树18 小时前
css 的回溯机制、CSS 层级过深的选择器会影响浏览器的性能
前端·css
吃吃今天努力学习了吗18 小时前
【论文阅读】Gaussian Grouping: Segment and Edit Anything in 3D Scenes
论文阅读·计算机视觉·3d·3dgs·三维分割
光头程序员18 小时前
Vite 前端项目 - CSS变量智能提示
前端·css
CG_MAGIC1 天前
用ZBrush和Blender制作波洛3D肖像
3d·blender·效果图渲染·zbrush·渲云渲染