回答編集履歴

3

ソースも

2021/03/18 06:03

投稿

FKM
FKM

スコア3640

test CHANGED
@@ -35,3 +35,289 @@
35
35
 
36
36
 
37
37
  それからz-indesなんてプロパティはありません。z-indexですね。
38
+
39
+
40
+
41
+ ```html
42
+
43
+ <!DOCTYPE html>
44
+
45
+ <html lang="en">
46
+
47
+ <head>
48
+
49
+ <meta charset="UTF-8">
50
+
51
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
52
+
53
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
54
+
55
+ <title>Document</title>
56
+
57
+ <style>
58
+
59
+ html,
60
+
61
+ body {
62
+
63
+ width: 100%;
64
+
65
+ height: 100%;
66
+
67
+ margin: 0;
68
+
69
+ cursor: none;
70
+
71
+ }
72
+
73
+
74
+
75
+ body {
76
+
77
+ position: relative;
78
+
79
+ cursor: none;
80
+
81
+ }
82
+
83
+
84
+
85
+ .cursor,
86
+
87
+ .follower {
88
+
89
+ border-radius: 50%;
90
+
91
+ position: absolute;
92
+
93
+ top: 0;
94
+
95
+ left: 0;
96
+
97
+ pointer-events: none;
98
+
99
+ }
100
+
101
+
102
+
103
+ .cursor {
104
+
105
+ width: 8px;
106
+
107
+ height: 8px;
108
+
109
+ background-color: #000;
110
+
111
+ z-index: 1001;
112
+
113
+ }
114
+
115
+
116
+
117
+ .follower {
118
+
119
+ display: flex;
120
+
121
+ justify-content: center;
122
+
123
+ align-items: center;
124
+
125
+ width: 40px;
126
+
127
+ height: 40px;
128
+
129
+ background-color: rgba(253,254,0,.5); /*ここを修正*/
130
+
131
+ z-index: 1000;
132
+
133
+ transition: transform ease .1s;
134
+
135
+ text-align: center;
136
+
137
+ span {
138
+
139
+ display: inline-block;
140
+
141
+ font-size: 14px;
142
+
143
+ font-weight: bold;
144
+
145
+ transform: scale(0);
146
+
147
+ }
148
+
149
+ &.is-active {
150
+
151
+ transform: scale(3);
152
+
153
+ }
154
+
155
+ }
156
+
157
+
158
+
159
+ .btn {
160
+
161
+ display: inline-block;
162
+
163
+ width: 160px;
164
+
165
+ margin: 16px;
166
+
167
+ text-align: center;
168
+
169
+ font-size: 16px;
170
+
171
+ line-height: 1;
172
+
173
+
174
+
175
+ a {
176
+
177
+ display: block;
178
+
179
+ color: #fff;
180
+
181
+ text-decoration: none;
182
+
183
+ padding: 16px;
184
+
185
+ background-color: #000;
186
+
187
+ cursor: none;
188
+
189
+ }
190
+
191
+ }
192
+
193
+ </style>
194
+
195
+ <script src="https://code.jquery.com/jquery-3.6.0.js"></script>
196
+
197
+ <script src="//cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js"></script>
198
+
199
+ </head>
200
+
201
+ <body>
202
+
203
+ <div class="btn"><a href="">Button</a></div>
204
+
205
+ <div class="cursor"></div>
206
+
207
+ <div class="follower"></div>
208
+
209
+
210
+
211
+ <script>
212
+
213
+ //DOM生成後でないとカーソルが動きません
214
+
215
+ var
216
+
217
+ cursor = $(".cursor"),
218
+
219
+ follower = $(".follower"),
220
+
221
+ cWidth = 8, //カーソルの大きさ
222
+
223
+ fWidth = 40, //フォロワーの大きさ
224
+
225
+ delay = 10, //数字を大きくするとフォロワーがより遅れて来る
226
+
227
+ mouseX = 0, //マウスのX座標
228
+
229
+ mouseY = 0, //マウスのY座標
230
+
231
+ posX = 0, //フォロワーのX座標
232
+
233
+ posY = 0; //フォロワーのX座標
234
+
235
+
236
+
237
+ //カーソルの遅延アニメーション
238
+
239
+ //ほんの少ーーーしだけ遅延させる 0.001秒
240
+
241
+ TweenMax.to({}, .001, {
242
+
243
+ repeat: -1,
244
+
245
+ onRepeat: function() {
246
+
247
+ posX += (mouseX - posX) / delay;
248
+
249
+ posY += (mouseY - posY) / delay;
250
+
251
+
252
+
253
+ TweenMax.set(follower, {
254
+
255
+ css: {
256
+
257
+ left: posX - (fWidth / 2),
258
+
259
+ top: posY - (fWidth / 2)
260
+
261
+ }
262
+
263
+ });
264
+
265
+
266
+
267
+ TweenMax.set(cursor, {
268
+
269
+ css: {
270
+
271
+ left: mouseX - (cWidth / 2),
272
+
273
+ top: mouseY - (cWidth / 2)
274
+
275
+ }
276
+
277
+ });
278
+
279
+ }
280
+
281
+ });
282
+
283
+
284
+
285
+ //マウス座標を取得
286
+
287
+ $(document).on("mousemove", function(e) {
288
+
289
+ mouseX = e.pageX;
290
+
291
+ mouseY = e.pageY;
292
+
293
+ });
294
+
295
+
296
+
297
+ $("a").on({
298
+
299
+ "mouseenter": function() {
300
+
301
+ cursor.addClass("is-active");
302
+
303
+ follower.addClass("is-active");
304
+
305
+ },
306
+
307
+ "mouseleave": function() {
308
+
309
+ cursor.removeClass("is-active");
310
+
311
+ follower.removeClass("is-active");
312
+
313
+ }
314
+
315
+ });
316
+
317
+
318
+
319
+ </script>
320
+
321
+ </body>
322
+
323
+ ```

2

コンパイルの件

2021/03/18 06:03

投稿

FKM
FKM

スコア3640

test CHANGED
@@ -14,9 +14,9 @@
14
14
 
15
15
 
16
16
 
17
- ## scssはcssファイルとしてコンパイルされた状態
17
+ ## scssは直接読み込めない
18
18
 
19
- したがって、呼び出すファイルはcssです。
19
+ したがって、呼び出すファイルはcssです。htmlから読み込むためには、cssファイルとしてコンパイルされた状態にしないといけません。
20
20
 
21
21
 
22
22
 

1

cssのミス

2021/03/18 05:58

投稿

FKM
FKM

スコア3640

test CHANGED
@@ -30,7 +30,7 @@
30
30
 
31
31
 
32
32
 
33
- なので、**#fdfe00の場合はrgba(253,254,0,0,5)となる**はずです。
33
+ なので、**#fdfe00の場合はrgba(253,254,0, .5)となる**はずです。
34
34
 
35
35
 
36
36