# css 按下效果

<div class='container'>
    <div class='base'>
        <button class='btn-wrapper' ontouchstart=''>
            <div class='btn-side'></div>
            <div class='btn'>
                S
            </div>
        </button>
    </div>
</div>

<style>
    body {
    background: #272822;
    margin: 0;
    perspective: 600px;
}
/* Button container */

.container {
    margin: 15px auto;
    width: 240px;
    height: 240px;
    transform: rotateX(40deg);
    transform-style: preserve-3d;
}
/* Light gray bottom part */

.base {
    background: #bbb;
    border-radius: 16px;
    box-shadow: 0 -6px 0px #777777 inset;
    display: flex;
    display: -webkit-flex;
    justify-content: center;
    -webkit-justify-content: center;
    align-items: center;
    -webkit-align-items: center;
    position: relative;
    transform-style: preserve-3d;
    width: 240px;
    height: 240px;
}
/* Clickable area containing both dark gray parts of button */

.btn-wrapper {
    border: 0;
    background: transparent;
    cursor: pointer;
    -webkit-appearance: none;
}
.btn-wrapper:active .btn {
    transform: translateZ(1px);
}
.btn-wrapper:active .btn-side {
    transform: translateZ(0);
}
.btn-wrapper:focus {
    outline: none;
}
/* Top of button */

.btn {
    background: #444 linear-gradient(#888888, transparent 50%);
    border-radius: 16px;
    box-shadow: 0 0 5px #888888 inset;
    color: #f80;
    display: block;
    font: 178.5px Asap;
    font-weight: bold;
    width: 210px;
    height: 210px;
    transform: translateZ(36px);
    transition: all 0.05s;
    text-align: center;
    text-shadow: 0 0 24px #f80, 0 -2.4px 0 #222222, 0 2.4px 0 #ffbb33;
    z-index: 2;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}
/* Shown side of button */

.btn-side {
    background: #333333 linear-gradient(90deg, #666666, transparent 8%, transparent 92%, #666666);
    border-radius: 0 0 12px 12px;
    box-shadow: 0 -4.8px 4.8px #222 inset;
    position: absolute;
    bottom: 8%;
    transform: rotateX(-60deg);
    transform-origin: 0 100%;
    transition: all 0.05s;
    width: 210px;
    height: 31.5px;
    z-index: 1;
}
</style>
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
92
93
94
95
96
97