hooyantsing's Blog

P158_7_漂亮的动感表单效果

字数统计: 254阅读时长: 1 min
2020/04/21

P158 7 漂亮的动感表单效果

实战案例

介绍:

1、使用transform动态的居中。

2、选中input底部会有彩条动画。

效果:

c80eb89e95ef2b5b7aec8dafbeeb05d4.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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            background: #34495e;
        }
        main{
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%,-50%);
            width: 300px;
            height: 300px;
            border: solid 5px silver;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
        }
        .field{
            position: relative;
            overflow: hidden;
            margin-bottom: 10px;
        }
        .field::before{
            content: '';
            position: absolute;
            background: linear-gradient(to right,white,blueviolet,goldenrod,orangered,white);
            height: 5px;
            width: 100%;
            left: 0;
            bottom: 0;
            transform: translate(-100%);
            transition: 2s;
        }
        .field:hover::before{
            transform: translate(100%);
        }
        .field input{
            border: none;
            outline: none;
            background: #ecf0f1;
            padding: 10px;
        }
    </style>
</head>
<body>
<main>
    <div class="field">
        <input type="text" placeholder="请输入后盾人账号">
    </div>
    <div class="field">
        <input type="text" placeholder="请输入密码">
    </div>
</main>
</body>
</html>
CATALOG