hooyantsing's Blog

P187_36_3D旋转图集真的很简单

字数统计: 305阅读时长: 1 min
2020/04/23

P187 36 3D旋转图集真的很简单

实战案例

效果:

92be1e099ec13359dc0f435f38304bb5.png

1f917d6eb91354ae6668a2a31892f9df.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        body {
            height: 100vh;
            width: 100vw;
            display: flex;
            justify-content: center;
            align-items: center;
            background: #2c3e50;
        }

        article {
            width: 400px;
            height: 400px;
            border: solid 1px silver;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        article:hover main {
            transform: perspective(900px) rotateX(-45deg) rotateY(360deg);
        }

        main {
            width: 200px;
            height: 200px;
            display: flex;
            border: solid 5px silver;
            transform-origin: center center -200px;
            transform-style: preserve-3d;
            transform: perspective(900px) rotateX(-45deg);
            transition: 2s;
        }

        div {
            position: absolute;
            width: 200px;
            height: 200px;
            overflow: hidden;
        }

        div > img {
            height: 100%;
        }

        div:nth-child(1) {
            transform-origin: center center -200px;
            transform: rotateY(90deg);
        }

        div:nth-child(2) {
            transform-origin: center center -200px;
            transform: rotateY(180deg);
        }

        div:nth-child(3) {
            transform-origin: center center -200px;
            transform: rotateY(270deg);
        }

        div:nth-child(4) {
            transform-origin: center center -200px;
            transform: rotateY(360deg);
        }
    </style>
</head>
<body>
<article>
    <main>
        <div><img src="1.jpg" alt=""></div>
        <div><img src="2.jpg" alt=""></div>
        <div><img src="3.JPG" alt=""></div>
        <div><img src="4.jpg" alt=""></div>
    </main>
</article>
</body>
</html>
CATALOG