回答編集履歴

2

追記再び

2019/05/10 05:18

投稿

LibertyBell3
LibertyBell3

スコア1084

test CHANGED
@@ -229,3 +229,135 @@
229
229
  `tbody tr:not(:last-of-type) td:last-child`を`tbody tr td:last-child`に変更して、
230
230
 
231
231
  中身を`margin-bottom:10px;`などとしてください。
232
+
233
+
234
+
235
+ 追記2:
236
+
237
+
238
+
239
+ HTMLは`<thead>`の`<th>`内と`<tbody>`の`<th>`内が変更点です。
240
+
241
+ CSSは`tbody th{}`内に以下の1行を追加。
242
+
243
+ `tbody th::after{}`はそのまま追加します。
244
+
245
+ 要するにレイヤーで上書きって感じになります。
246
+
247
+ HTMLのソース上構造は間違っていないので、問題ないと思いますが、
248
+
249
+ やっちゃだめなことだとご存知の方はコメントください。
250
+
251
+
252
+
253
+ ```HTML
254
+
255
+ <body>
256
+
257
+ <div class="container">
258
+
259
+ <table>
260
+
261
+ <thead>
262
+
263
+ <tr>
264
+
265
+ <th>&nbsp;</th>
266
+
267
+ <th>C1</th>
268
+
269
+ <th>C2</th>
270
+
271
+ <th>C3</th>
272
+
273
+ </tr>
274
+
275
+ </thead>
276
+
277
+ <tbody>
278
+
279
+ <tr>
280
+
281
+ <th data-label="C1">30min</th>
282
+
283
+ <td data-label="30min">100</td>
284
+
285
+ <td data-label="45min">200</td>
286
+
287
+ <td data-label="60min">300</td>
288
+
289
+ </tr>
290
+
291
+ <tr>
292
+
293
+ <th data-label="C2">45min</th>
294
+
295
+ <td data-label="30min">200</td>
296
+
297
+ <td data-label="45min">300</td>
298
+
299
+ <td data-label="60min">400</td>
300
+
301
+ </tr>
302
+
303
+ <tr>
304
+
305
+ <th data-label="C3">60min</th>
306
+
307
+ <td data-label="30min">300</td>
308
+
309
+ <td data-label="45min">400</td>
310
+
311
+ <td data-label="60min">500</td>
312
+
313
+ </tr>
314
+
315
+ </tbody>
316
+
317
+ </table>
318
+
319
+ </div>
320
+
321
+ </body>
322
+
323
+ ```
324
+
325
+ ```CSS
326
+
327
+ @media only screen and (max-width:480px) {
328
+
329
+ tbody th {
330
+
331
+ position:relative;
332
+
333
+ }
334
+
335
+ tbody th::after {
336
+
337
+ z-index:10;
338
+
339
+ position:absolute;
340
+
341
+ left:0;
342
+
343
+ top:0;
344
+
345
+ display:flex;
346
+
347
+ justify-content:center;
348
+
349
+ align-items:center;
350
+
351
+ background-color:#ff0;
352
+
353
+ width:100%;
354
+
355
+ height:100%;
356
+
357
+ content:attr(data-label);
358
+
359
+ }
360
+
361
+ }
362
+
363
+ ```

1

追記です。

2019/05/10 05:17

投稿

LibertyBell3
LibertyBell3

スコア1084

test CHANGED
@@ -217,3 +217,15 @@
217
217
  ```
218
218
 
219
219
  不明点あればご質問ください。
220
+
221
+
222
+
223
+ 追記:
224
+
225
+
226
+
227
+ サンプル画像のように三項目の間にスペースを入れる場合。
228
+
229
+ `tbody tr:not(:last-of-type) td:last-child`を`tbody tr td:last-child`に変更して、
230
+
231
+ 中身を`margin-bottom:10px;`などとしてください。