hooyantsing's Blog

P193_42_优美的会员注册卡片效果

字数统计: 339阅读时长: 2 min
2020/04/23

P193 42 优美的会员注册卡片效果

实战案例

介绍:涉及到jquery的应用。对backface-visibility:hidden的练习。

效果:

d3b6fd1c6f45a6ae9830bc9a95a80ce2.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
88
89
90
91
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-3.3.1.min.js"></script>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        main {
            width: 100vw;
            height: 100vh;
            transform-style: preserve-3d;
            transform: perspective(900px);
            transition: 1s;
        }

       /* body:hover main {
            transform: perspective(900px) rotateY(180deg);
        }*/

        main.login{
            transform: perspective(900px) rotateY(0deg);
        }
        main.register{
            transform: perspective(900px) rotateY(180deg);
        }

        div {
            position: absolute;
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 4em;
            text-transform: uppercase;
            color: white;
            backface-visibility: hidden;
        }

        div:nth-child(1) {
            background: #8e44ad;
        }

        div:nth-child(2) {
            background: #e74c3c;
            transform: rotateY(180deg);
        }

        nav {
            position: absolute;
            width: 100%;
            bottom: 60px;
            text-align: center;
        }

        nav a {
            padding: 10px 20px;
            background: #34495e;
            margin-right: 10px;
            color: white;
            text-decoration: none;
        }
    </style>
</head>
<body>
<main>
    <div>login</div>
    <div>register</div>
</main>
<nav>
    <a href="javascript:;" onclick="change('login')">登录</a>
    <a href="javascript:;" onclick="change('register')">注册</a>
</nav>
<script>
    function change(t) {
        switch (t) {
            case 'login':
                $('main').removeClass().addClass('login');
                break;
            case 'register':
                $('main').removeClass().addClass('register');
        }
    }
</script>
</body>
</html>
CATALOG