回答編集履歴

1

擬似要素を利用するパターンの追記

2016/08/31 02:44

投稿

yamato_hikawa
yamato_hikawa

スコア2092

test CHANGED
@@ -211,3 +211,217 @@
211
211
  }
212
212
 
213
213
  ```
214
+
215
+
216
+
217
+ #afterを利用した例
218
+
219
+ a9を使わず、a8のafterに小さな四角形を設定する例が下記です。
220
+
221
+
222
+
223
+ ```css
224
+
225
+ .box {
226
+
227
+ margin: auto;
228
+
229
+ height: 500px;
230
+
231
+ width: 500px;
232
+
233
+ position: relative;
234
+
235
+ background-color: #ECF1F2;
236
+
237
+ }
238
+
239
+
240
+
241
+ .a1,
242
+
243
+ .a2,
244
+
245
+ .a3,
246
+
247
+ .a4,
248
+
249
+ .a5,
250
+
251
+ .a6,
252
+
253
+ .a7,
254
+
255
+ .a8,
256
+
257
+ .a8::after,
258
+
259
+ {
260
+
261
+ position: absolute;
262
+
263
+ }
264
+
265
+
266
+
267
+ .a1,
268
+
269
+ .a2,
270
+
271
+ .a3,
272
+
273
+ .a4,
274
+
275
+ .a5,
276
+
277
+ .a6,
278
+
279
+ .a7,
280
+
281
+ .a8 {
282
+
283
+ width: 100px;
284
+
285
+ height: 100px;
286
+
287
+ }
288
+
289
+
290
+
291
+ .a1,
292
+
293
+ .a8::after {
294
+
295
+ background-color: #ffefd3;
296
+
297
+ }
298
+
299
+
300
+
301
+ .a1 {
302
+
303
+ z-index: 1;
304
+
305
+ top: 40px;
306
+
307
+ left: 200px;
308
+
309
+ }
310
+
311
+
312
+
313
+ .a2 {
314
+
315
+ z-index: 2;
316
+
317
+ top: 120px;
318
+
319
+ left: 280px;
320
+
321
+ background-color: #7084de;
322
+
323
+ }
324
+
325
+
326
+
327
+ .a3 {
328
+
329
+ z-index: 3;
330
+
331
+ top: 200px;
332
+
333
+ left: 360px;
334
+
335
+ background-color: #d0ecea;
336
+
337
+ }
338
+
339
+
340
+
341
+ .a4 {
342
+
343
+ z-index: 4;
344
+
345
+ top: 280px;
346
+
347
+ left: 280px;
348
+
349
+ background-color: #8d7a5e;
350
+
351
+ }
352
+
353
+
354
+
355
+ .a5 {
356
+
357
+ z-index: 5;
358
+
359
+ top: 360px;
360
+
361
+ left: 200px;
362
+
363
+ background-color: #9fd6d2;
364
+
365
+ }
366
+
367
+
368
+
369
+ .a6 {
370
+
371
+ z-index: 6;
372
+
373
+ top: 280px;
374
+
375
+ left: 120px;
376
+
377
+ background-color: #fffee4;
378
+
379
+ }
380
+
381
+
382
+
383
+ .a7 {
384
+
385
+ z-index: 7;
386
+
387
+ top: 200px;
388
+
389
+ left: 40px;
390
+
391
+ background-color: #deae70;
392
+
393
+ }
394
+
395
+
396
+
397
+ .a8 {
398
+
399
+ z-index: 8;
400
+
401
+ top: 120px;
402
+
403
+ left: 120px;
404
+
405
+ background-color: #de70cf;
406
+
407
+ position: absolute;
408
+
409
+ }
410
+
411
+
412
+
413
+ .a8::after {
414
+
415
+ content: "";
416
+
417
+ top: 0;
418
+
419
+ left: 80px;
420
+
421
+ height: 20px;
422
+
423
+ width: 20px;
424
+
425
+ }
426
+
427
+ ```