hooyantsing's Blog

P177_26_3D新年快乐贺卡制作

字数统计: 227阅读时长: 1 min
2020/04/22

P177 26 3D新年快乐贺卡制作

实战案例

介绍:练习参考点旋转

效果:

a39ecc5f3e57c246fd0db4167e705819.png

源码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }
        body{
            height: 100vh;
            width: 100vw;
            background: #2c3e50;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        div{
            height: 200px;
            width: 300px;
            background: #e67e22;
            display: flex;
            justify-content: center;
            align-items: center;
            color: white;
            font-size: 2em;
            position: relative;
            transform-style: preserve-3d;
            transform: perspective(900px) rotateX(25deg) rotateY(15deg);
        }
        div::before,
        div::after{
            height: 100%;
            width: 50%;
            position: absolute;
            display: flex;
            align-items: center;
            background: #e74c3c;
            transition: 1s;
        }
        div::before{
            content: '新年';
            top: 0;
            left: 0;
            justify-content: flex-end;
            transform-origin: left;
        }
        div::after{
            content: '快乐';
            top: 0;
            right: 0;
            justify-content: flex-start;
            transform-origin: right;
        }
        div:hover::before{
            transform: rotateY(-180deg);
        }
        div:hover::after{
            transform: rotateY(180deg);
        }
    </style>
</head>
<body>
<div class="card">houdunren</div>
</body>
</html>
CATALOG