回答編集履歴

2

書式の改善

2020/08/22 07:38

投稿

Jon_do
Jon_do

スコア1373

test CHANGED
@@ -1,8 +1,6 @@
1
1
  やり方は色々あると思いますが、下記のような方法で可能です。
2
2
 
3
- (mac、chrome動作確認しました。)
3
+ 方法1 メディアクエリ分ける
4
-
5
-
6
4
 
7
5
  ```html5
8
6
 
@@ -131,3 +129,251 @@
131
129
  </html>
132
130
 
133
131
  ```
132
+
133
+ 方法2 画像を使う
134
+
135
+ ```HTML
136
+
137
+ <!DOCTYPE html>
138
+
139
+ <html lang="ja">
140
+
141
+
142
+
143
+ <head>
144
+
145
+ <meta charset="UTF-8">
146
+
147
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
148
+
149
+ <title>Document</title>
150
+
151
+ <style>
152
+
153
+ .videoWrap {
154
+
155
+ width: 80vw;
156
+
157
+ max-width: 640px;
158
+
159
+ background-size: contain;
160
+
161
+ margin: 0 auto;
162
+
163
+ position: relative;
164
+
165
+ }
166
+
167
+
168
+
169
+ video {
170
+
171
+ width: 100%;
172
+
173
+ }
174
+
175
+
176
+
177
+ a {
178
+
179
+ display: block;
180
+
181
+ position: absolute;
182
+
183
+ width: 45%;
184
+
185
+ max-width: 288px;
186
+
187
+ height: 25%;
188
+
189
+ background-image: url(https://f.easyuploader.app/eu-prd/upload/20200822160950_5a7a43327a4f45315375.png);
190
+
191
+ background-size: contain;
192
+
193
+ background-repeat: no-repeat;
194
+
195
+ text-decoration: none;
196
+
197
+ color: rgb(230, 230, 230);
198
+
199
+ bottom: -8%;
200
+
201
+ left: -8%;
202
+
203
+ }
204
+
205
+ </style>
206
+
207
+ </head>
208
+
209
+
210
+
211
+ <body>
212
+
213
+ <div class="videoWrap">
214
+
215
+ <video autoplay muted loop>
216
+
217
+ <source src="https://f.easyuploader.app/eu-prd/upload/20200820123159_475a4850713442547259.mp4"
218
+
219
+ type="video/mp4" />
220
+
221
+ </video>
222
+
223
+ <a href="https://pixabay.com/videos/underwater-sea-ocean-water-37712/"></a>
224
+
225
+ </div>
226
+
227
+ </body>
228
+
229
+
230
+
231
+ </html>
232
+
233
+ ```
234
+
235
+ 方法3 Javascriptで制御
236
+
237
+ ```HTML
238
+
239
+ <!DOCTYPE html>
240
+
241
+ <html lang="ja">
242
+
243
+
244
+
245
+ <head>
246
+
247
+ <meta charset="UTF-8">
248
+
249
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
250
+
251
+ <title>Document</title>
252
+
253
+ <style>
254
+
255
+ .videoWrap {
256
+
257
+ width: 80vw;
258
+
259
+ max-width: 640px;
260
+
261
+ background-size: contain;
262
+
263
+ margin: 0 auto;
264
+
265
+ position: relative;
266
+
267
+ }
268
+
269
+
270
+
271
+ video {
272
+
273
+ width: 100%;
274
+
275
+ }
276
+
277
+
278
+
279
+ a {
280
+
281
+ display: block;
282
+
283
+ position: absolute;
284
+
285
+ font-size: 0;
286
+
287
+ line-height: 0;
288
+
289
+ width: 45%;
290
+
291
+ max-width: 288px;
292
+
293
+ height: 25%;
294
+
295
+ background-color: rgba(0, 0, 0, 0.548);
296
+
297
+ text-decoration: none;
298
+
299
+ text-align: center;
300
+
301
+ color: rgb(230, 230, 230);
302
+
303
+ bottom: -8%;
304
+
305
+ left: -8%;
306
+
307
+ }
308
+
309
+ </style>
310
+
311
+ </head>
312
+
313
+
314
+
315
+ <body>
316
+
317
+ <div class="videoWrap">
318
+
319
+ <video autoplay muted loop>
320
+
321
+ <source src="https://f.easyuploader.app/eu-prd/upload/20200820123159_475a4850713442547259.mp4"
322
+
323
+ type="video/mp4" />
324
+
325
+ </video>
326
+
327
+ <a href="https://pixabay.com/videos/underwater-sea-ocean-water-37712/">フリー&再配布OK!</a>
328
+
329
+ </div>
330
+
331
+ <script>
332
+
333
+
334
+
335
+ window.addEventListener("resize", () => {
336
+
337
+ setTimeout(fontAdjust, 10);
338
+
339
+ });
340
+
341
+
342
+
343
+ window.addEventListener("load", () => {
344
+
345
+ setTimeout(fontAdjust, 50);
346
+
347
+ });
348
+
349
+
350
+
351
+ const fontAdjust = () => {
352
+
353
+ const a = document.getElementsByTagName("a")[0];
354
+
355
+ const aHeight = a.clientHeight;
356
+
357
+ const fontSize = aHeight * 0.33;
358
+
359
+ a.style.fontSize = fontSize + "px";
360
+
361
+ a.style.lineHeight = aHeight + "px";
362
+
363
+ }
364
+
365
+
366
+
367
+
368
+
369
+ </script>
370
+
371
+
372
+
373
+ </body>
374
+
375
+
376
+
377
+ </html>
378
+
379
+ ```

1

誤字の修正

2020/08/22 07:38

投稿

Jon_do
Jon_do

スコア1373

test CHANGED
@@ -1,6 +1,6 @@
1
1
  やり方は色々あると思いますが、下記のような方法で可能です。
2
2
 
3
- (google mac、chromeで動作確認しました。)
3
+ (mac、chromeで動作確認しました。)
4
4
 
5
5
 
6
6