回答編集履歴
1
a
test
CHANGED
@@ -1,3 +1,181 @@
|
|
1
1
|
ボタンを中心に広がるアニメーション部分のみ作ってみました。
|
2
2
|
|
3
3
|
[コードペン](https://codepen.io/KazuSaka/pen/dyPZLBV)
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
以下コード。
|
8
|
+
|
9
|
+
```html
|
10
|
+
|
11
|
+
<!DOCTYPE html>
|
12
|
+
|
13
|
+
<html>
|
14
|
+
|
15
|
+
<head>
|
16
|
+
|
17
|
+
<meta charset="utf-8">
|
18
|
+
|
19
|
+
<meta name="viewport" content="width=device-width">
|
20
|
+
|
21
|
+
<link href="style.css" rel="stylesheet">
|
22
|
+
|
23
|
+
<title>JS Bin</title>
|
24
|
+
|
25
|
+
</head>
|
26
|
+
|
27
|
+
<body>
|
28
|
+
|
29
|
+
<div class="wrap">
|
30
|
+
|
31
|
+
<button id="back-button"></button><!-- ボタンの背後に配置(中心から徐々に大きくする用) -->
|
32
|
+
|
33
|
+
<button id="front-button" onmousedown="down();" onmouseup="up();">change</button>
|
34
|
+
|
35
|
+
</div>
|
36
|
+
|
37
|
+
</body>
|
38
|
+
|
39
|
+
</html>
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
<script type="text/javascript">
|
46
|
+
|
47
|
+
var eb = document.getElementById("back-button"); //ボタンの背後
|
48
|
+
|
49
|
+
var ef = document.getElementById("front-button"); //ボタン自体
|
50
|
+
|
51
|
+
var down = function() {
|
52
|
+
|
53
|
+
eb.style.display = "block"; //ボタンの背後の要素を表示
|
54
|
+
|
55
|
+
eb.style.animation = "animation 2s ease";
|
56
|
+
|
57
|
+
ef.style.background = "white";
|
58
|
+
|
59
|
+
ef.style.color = "tomato";
|
60
|
+
|
61
|
+
ef.style.transition = "2s";
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
var up = function() {
|
68
|
+
|
69
|
+
eb.style.animation = "animation2 2s ease";
|
70
|
+
|
71
|
+
eb.style.display = "none"; //ボタンの背後を非表示
|
72
|
+
|
73
|
+
ef.style.background = "tomato"; //ボタンの色を戻す
|
74
|
+
|
75
|
+
ef.style.color = "white"; //ボタンの色を戻す
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
</script>
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
```css
|
88
|
+
|
89
|
+
body {
|
90
|
+
|
91
|
+
width: 100vw;
|
92
|
+
|
93
|
+
height: 100vh;
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
.wrap{
|
98
|
+
|
99
|
+
position: relative;
|
100
|
+
|
101
|
+
width: 70px;
|
102
|
+
|
103
|
+
height: 70px;
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
button{
|
108
|
+
|
109
|
+
position: absolute;
|
110
|
+
|
111
|
+
top: 0;
|
112
|
+
|
113
|
+
left: 0;
|
114
|
+
|
115
|
+
color: white;
|
116
|
+
|
117
|
+
background: tomato;
|
118
|
+
|
119
|
+
border: none;
|
120
|
+
|
121
|
+
border-radius: 50%;
|
122
|
+
|
123
|
+
width: 70px;
|
124
|
+
|
125
|
+
height: 70px;
|
126
|
+
|
127
|
+
}
|
128
|
+
|
129
|
+
#back-button{
|
130
|
+
|
131
|
+
display: none;
|
132
|
+
|
133
|
+
position: absolute;
|
134
|
+
|
135
|
+
top:50%;
|
136
|
+
|
137
|
+
left:50%;
|
138
|
+
|
139
|
+
transform: translate(-50%, -50%);
|
140
|
+
|
141
|
+
color: black;
|
142
|
+
|
143
|
+
background: red;
|
144
|
+
|
145
|
+
border: none;
|
146
|
+
|
147
|
+
border-radius: 50%;
|
148
|
+
|
149
|
+
width: 5000px;
|
150
|
+
|
151
|
+
height: 5000px;
|
152
|
+
|
153
|
+
padding:0;
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
@keyframes animation {
|
160
|
+
|
161
|
+
0% {
|
162
|
+
|
163
|
+
width: 0%;
|
164
|
+
|
165
|
+
height: 0%;
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
100% {
|
170
|
+
|
171
|
+
width: 5000px;
|
172
|
+
|
173
|
+
height:5000px;
|
174
|
+
|
175
|
+
}
|
176
|
+
|
177
|
+
}
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
```
|