質問するログイン新規登録

回答編集履歴

2

書式の改善

2020/08/22 07:38

投稿

Jon_do
Jon_do

スコア1373

answer CHANGED
@@ -1,6 +1,5 @@
1
1
  やり方は色々あると思いますが、下記のような方法で可能です。
2
- (mac、chrome動作確認しました。)
2
+ 方法1 メディアクエリ分ける
3
-
4
3
  ```html5
5
4
  <!DOCTYPE html>
6
5
  <html lang="en">
@@ -64,4 +63,128 @@
64
63
  </body>
65
64
 
66
65
  </html>
66
+ ```
67
+ 方法2 画像を使う
68
+ ```HTML
69
+ <!DOCTYPE html>
70
+ <html lang="ja">
71
+
72
+ <head>
73
+ <meta charset="UTF-8">
74
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
75
+ <title>Document</title>
76
+ <style>
77
+ .videoWrap {
78
+ width: 80vw;
79
+ max-width: 640px;
80
+ background-size: contain;
81
+ margin: 0 auto;
82
+ position: relative;
83
+ }
84
+
85
+ video {
86
+ width: 100%;
87
+ }
88
+
89
+ a {
90
+ display: block;
91
+ position: absolute;
92
+ width: 45%;
93
+ max-width: 288px;
94
+ height: 25%;
95
+ background-image: url(https://f.easyuploader.app/eu-prd/upload/20200822160950_5a7a43327a4f45315375.png);
96
+ background-size: contain;
97
+ background-repeat: no-repeat;
98
+ text-decoration: none;
99
+ color: rgb(230, 230, 230);
100
+ bottom: -8%;
101
+ left: -8%;
102
+ }
103
+ </style>
104
+ </head>
105
+
106
+ <body>
107
+ <div class="videoWrap">
108
+ <video autoplay muted loop>
109
+ <source src="https://f.easyuploader.app/eu-prd/upload/20200820123159_475a4850713442547259.mp4"
110
+ type="video/mp4" />
111
+ </video>
112
+ <a href="https://pixabay.com/videos/underwater-sea-ocean-water-37712/"></a>
113
+ </div>
114
+ </body>
115
+
116
+ </html>
117
+ ```
118
+ 方法3 Javascriptで制御
119
+ ```HTML
120
+ <!DOCTYPE html>
121
+ <html lang="ja">
122
+
123
+ <head>
124
+ <meta charset="UTF-8">
125
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
126
+ <title>Document</title>
127
+ <style>
128
+ .videoWrap {
129
+ width: 80vw;
130
+ max-width: 640px;
131
+ background-size: contain;
132
+ margin: 0 auto;
133
+ position: relative;
134
+ }
135
+
136
+ video {
137
+ width: 100%;
138
+ }
139
+
140
+ a {
141
+ display: block;
142
+ position: absolute;
143
+ font-size: 0;
144
+ line-height: 0;
145
+ width: 45%;
146
+ max-width: 288px;
147
+ height: 25%;
148
+ background-color: rgba(0, 0, 0, 0.548);
149
+ text-decoration: none;
150
+ text-align: center;
151
+ color: rgb(230, 230, 230);
152
+ bottom: -8%;
153
+ left: -8%;
154
+ }
155
+ </style>
156
+ </head>
157
+
158
+ <body>
159
+ <div class="videoWrap">
160
+ <video autoplay muted loop>
161
+ <source src="https://f.easyuploader.app/eu-prd/upload/20200820123159_475a4850713442547259.mp4"
162
+ type="video/mp4" />
163
+ </video>
164
+ <a href="https://pixabay.com/videos/underwater-sea-ocean-water-37712/">フリー&再配布OK!</a>
165
+ </div>
166
+ <script>
167
+
168
+ window.addEventListener("resize", () => {
169
+ setTimeout(fontAdjust, 10);
170
+ });
171
+
172
+ window.addEventListener("load", () => {
173
+ setTimeout(fontAdjust, 50);
174
+ });
175
+
176
+ const fontAdjust = () => {
177
+ const a = document.getElementsByTagName("a")[0];
178
+ const aHeight = a.clientHeight;
179
+ const fontSize = aHeight * 0.33;
180
+ a.style.fontSize = fontSize + "px";
181
+ a.style.lineHeight = aHeight + "px";
182
+ }
183
+
184
+
185
+ </script>
186
+
187
+ </body>
188
+
189
+ </html>
67
190
  ```

1

誤字の修正

2020/08/22 07:38

投稿

Jon_do
Jon_do

スコア1373

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