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

相关推荐
软件技术NINI2 小时前
美妆商城html+Css+js 4页
javascript·css·html
Jmyd01238 小时前
文物3D扫描采集系统选型与集成:固定+手持双链路技术方案
3d·文物修复·文物数字化·文物建模
2603_965896628 小时前
Grid 网格布局|CSS 二维页面排版体系
前端·css
博图光电9 小时前
笔记本键盘漏光缺陷检测
人工智能·数码相机·3d·自动化
多喝水身体棒9 小时前
# CSS Grid布局入门,二维布局再也不用float了
css
软件技术NINI11 小时前
化妆品html+css+js 7页
javascript·css·html
程序猿追13 小时前
在 HarmonyOS 6 上做了张 3D 翻转卡片,正面背面来回翻
3d·华为·harmonyos
Solange__13 小时前
工业产线怎么用AI生成3D场景?从现场采集、部件重建到数字孪生交付的完整方案
人工智能·游戏·3d·ai·语言模型·自然语言处理·关卡设计
kaixin_learn_qt_ing13 小时前
hexdump -C /path/to/binary | less 看十六进制内容
前端·css·less
Martina_032114 小时前
一张地图怎么生成可编辑3D地形?用6步检查高度图、道路约束与Mesh导出
图像处理·人工智能·平面·3d·ai·自然语言处理·游戏策划