質問編集履歴

4

追記

2020/03/28 01:37

投稿

natsu_kawa
natsu_kawa

スコア15

test CHANGED
@@ -1 +1 @@
1
- img要素をウィンドウに合わせ、縦横比を保ったまま縮小させたい。
1
+ img要素をウィンドウに合わせ、縦横比を保ったまま縮小させたい。※追記修正
test CHANGED
@@ -1,4 +1,4 @@
1
- ### 画像をウィンドウに合わせ、縦横比を保ったまま縮小させたい。※追記修正
1
+ ### 画像をウィンドウに合わせ、縦横比を保ったまま縮小させたい。
2
2
 
3
3
 
4
4
 

3

追記

2020/03/28 01:37

投稿

natsu_kawa
natsu_kawa

スコア15

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- ### 画像をウィンドウに合わせ、縦横比を保ったまま縮小させたい。
1
+ ### 画像をウィンドウに合わせ、縦横比を保ったまま縮小させたい。※追記修正
2
2
 
3
3
 
4
4
 
@@ -500,6 +500,20 @@
500
500
 
501
501
  }
502
502
 
503
+ section{
504
+
505
+ padding: 10px 4%;
506
+
507
+ width: 80%;
508
+
509
+ }
510
+
511
+ img{
512
+
513
+ max-width: 100%;
514
+
515
+ }
516
+
503
517
 
504
518
 
505
519
  /*---------グッズ*---------
@@ -560,6 +574,10 @@
560
574
 
561
575
  の順で試しましたが変わりません。
562
576
 
577
+ 親要素にも幅を指定するなどしているんですが、そうするとウィンドウが縮小されていない状態でも画像が小さくなるなど
578
+
579
+ してしまいます。
580
+
563
581
  ### 補足情報(FW/ツールのバージョンなど)
564
582
 
565
583
  visual Studio Code

2

全体のコードを表示

2020/03/28 01:36

投稿

natsu_kawa
natsu_kawa

スコア15

test CHANGED
File without changes
test CHANGED
@@ -20,11 +20,135 @@
20
20
 
21
21
  ```ここに言語名を入力
22
22
 
23
+ <!doctype html>
24
+
25
+ <html lang="ja">
26
+
27
+ <head>
28
+
29
+ <meta charset="utf-8">
30
+
31
+ <title>aquamarine</title>
32
+
33
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
34
+
35
+ <link href="css/style.css" rel="stylesheet" type="text/css">
36
+
37
+ <link href="css/reset.css" rel="stylesheet" type="text/css">
38
+
39
+ </head>
40
+
41
+ <body>
42
+
43
+
44
+
45
+ <div id="index" class="big-bg">
46
+
47
+ <header class="page-header">
48
+
49
+ <nav>
50
+
23
- HTML5 CSS3
51
+ <ul>
52
+
24
-
53
+ <li><a href="#">about</a></li>
54
+
25
-
55
+ <li><a href="#">watercreatures</a></li>
56
+
26
-
57
+ <li><a href="#">goods</a></li>
58
+
59
+ <li><a href="#">contact</a></li>
60
+
61
+ </ul>
62
+
63
+ </nav>
64
+
65
+ <div class="wrapper">
66
+
67
+ <h1><img class="logo" src="images/logo1.png"></h1>
68
+
69
+ </div>
70
+
71
+ </header>
72
+
73
+ </div><!--#index.big-bg-->
74
+
75
+
76
+
77
+ <main>
78
+
79
+ <div class="about_bg">
80
+
81
+ <div id="about" class="wrapper">
82
+
83
+
84
+
85
+ <div class="txt_box">
86
+
87
+ <h2>海の生き物</h2>
88
+
89
+ <p>約30億年前に暖かくて浅い海底の堆積(たいせき)物中で地球最初の生物が生まれたといわれている。
90
+
91
+ そのころの地球の大気と海水中には遊離酸素がほとんどない状態であった。
92
+
93
+ 初期の生物は単細胞の細菌のような原核微生物であって、周囲の有機物を栄養源としていたが、
94
+
95
+ そのうち光合成能力をもつ藍藻(らんそう)(らん色細菌)が出現し、大気や海水に酸素を供給し始めた。
96
+
97
+ 酸素は大気の上層でオゾンとなり、オゾン層は生物に有害な紫外線を吸収し生命を守る傘となった。
98
+
99
+ それ以後、生物は水中や陸上に生活圏を広げ始め、環境に適応しながら進化して現在に至っている。</p>
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+ </div><!--.txt_box-->
108
+
109
+
110
+
111
+ <div class="update">
112
+
113
+
114
+
115
+ <h3>更新</h3>
116
+
117
+
118
+
119
+ <dl>
120
+
121
+ <dt>2020-5-5</dt><dd>goodsに新アイテム追加</dd><br>
122
+
123
+ <dt>2020-5-3</dt><dd>新しい生き物を追加</dd>
124
+
125
+ </dl>
126
+
127
+
128
+
129
+ </div><!--.update-->
130
+
131
+ </div><!--#about-->
132
+
133
+ </div>
134
+
135
+
136
+
137
+ <div id="watercreatures" class="big-bg">
138
+
139
+ <div class="page-header wrapper">
140
+
141
+
142
+
143
+ <h1><img class="logo" src="images/logo2.png"></h1>
144
+
145
+ </div><!--.page-header wrapper-->
146
+
147
+ </div><!--#watercreatures.big-bg-->
148
+
149
+
150
+
27
- <article>
151
+ <article>
28
152
 
29
153
  <div class="wrapper">
30
154
 
@@ -44,9 +168,363 @@
44
168
 
45
169
  </section>
46
170
 
171
+
172
+
173
+ <section class="Even_number">
174
+
175
+ <h4 class="sub-title">サメの仲間</h4>
176
+
177
+ <p></p>
178
+
179
+ <figuree class="img_box" >
180
+
181
+ <img src="images/sea2.jpg">
182
+
183
+ <figcaption>ヨゴレ</figcaption>
184
+
185
+ </figure>
186
+
187
+ </section>
188
+
189
+
190
+
191
+ <section>
192
+
193
+ <figure class="img_box">
194
+
195
+ <img src="images/sea3.jpg">
196
+
197
+ <figcaption>ゴマフアザラシ</figcaption>
198
+
199
+ </figure>
200
+
201
+ <h4 class="sub-title">アザラシの仲間</h4>
202
+
203
+ <p></p>
204
+
205
+ </section>
206
+
207
+
208
+
209
+ <section class="Even_number">
210
+
211
+ <h4 class="sub-title">ペンギンの仲間</h4>
212
+
213
+ <p></p>
214
+
215
+ <figure class="img_box">
216
+
217
+ <img src="images/sea4.jpg">
218
+
219
+ <figcaption>コウテイペンギン</figcaption>
220
+
221
+ </figure>
222
+
223
+ </section>
224
+
225
+
226
+
227
+
228
+
229
+ <section>
230
+
231
+ <figure class="img_box">
232
+
233
+ <img src="images/sea5.jpg">
234
+
235
+ <figcaption>マナティー</figcaption>
236
+
237
+ </figure>
238
+
239
+ <h4 class="sub-title">カイギュウの仲間</h4>
240
+
241
+ <p></p>
242
+
243
+ </section>
244
+
245
+
246
+
247
+ <section class="Even_number">
248
+
249
+ <h4 class="sub-title">軟体動物</h4>
250
+
251
+ <p></p>
252
+
253
+ <figure class="img_box">
254
+
255
+ <img src="images/sea6.jpg">
256
+
257
+ <figcaption>ミズダコ</figcaption>
258
+
259
+ </figure>
260
+
261
+ </section>
262
+
263
+
264
+
265
+ </div><!--.wrapper-->
266
+
267
+ </article>
268
+
269
+
270
+
271
+ <div id="goods" class="big-bg">
272
+
273
+
274
+
275
+ <div class="page-header wrapper">
276
+
277
+ <h1><img class="logo" src="images/logo3.png"></h1>
278
+
279
+ </div><!--.page-header-->
280
+
281
+
282
+
283
+ </div><!--#goods.big-bg-->
284
+
285
+ </main>
286
+
287
+
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+ </body>
298
+
299
+ </html>
300
+
301
+
302
+
303
+
304
+
47
305
  ```
48
306
 
49
-
307
+ ### CSS
308
+
309
+ ```@charset "utf-8";
310
+
311
+ /* CSS Document */
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+ /*---------共通---------
320
+
321
+ ^------------------------------*/
322
+
323
+ html{
324
+
325
+ font-size: 100%;
326
+
327
+ }
328
+
329
+ body{
330
+
331
+ background-color: #ccdaff;
332
+
333
+ font-family: "Yu Gothic Medium", "游ゴシック Medium", YuGothic, "游ゴシック体", "ヒラギノ角ゴ Pro W3", sans-serif;
334
+
335
+ line-height: 1.7;
336
+
337
+ color: whitesmoke;
338
+
339
+ color: black;
340
+
341
+ width: 100vw;
342
+
343
+ }
344
+
345
+ .wrapper{
346
+
347
+ width: 1400px;
348
+
349
+ margin: 0 auto;
350
+
351
+ padding: 0 3%;
352
+
353
+ }
354
+
355
+ .big-bg{
356
+
357
+ background-size: cover;
358
+
359
+ background-repeat: no-repeat;
360
+
361
+ background-position: center top;
362
+
363
+ }
364
+
365
+ #watercreatures,#goods{
366
+
367
+ margin-bottom: 50px;
368
+
369
+ }
370
+
371
+ #watercreatures,#goods{
372
+
373
+ height: 700px;
374
+
375
+ }
376
+
377
+
378
+
379
+
380
+
381
+ /*---------ヘッダー---------
382
+
383
+ ^------------------------------*/
384
+
385
+ #index{
386
+
387
+ background-image: url(../images/header1.5.jpg);
388
+
389
+ height: 100vh;
390
+
391
+ }
392
+
393
+ nav ul{
394
+
395
+ display: flex;
396
+
397
+ padding:0 30%;
398
+
399
+ margin: 0 auto;
400
+
401
+ justify-content: space-between;
402
+
403
+ background-color:rgba(255,255,255,0.5);
404
+
405
+ }
406
+
407
+ nav ul li {
408
+
409
+ list-style: none;
410
+
411
+ text-decoration: none;
412
+
413
+ }
414
+
415
+ .logo{
416
+
417
+ width: 300px;
418
+
419
+ }
420
+
421
+ #goods .logo{
422
+
423
+ width: 150px;
424
+
425
+ }
426
+
427
+ a{
428
+
429
+ text-decoration: none;
430
+
431
+ color: black;
432
+
433
+ }
434
+
435
+ a:hover{
436
+
437
+ color: blue;
438
+
439
+ }
440
+
441
+ /*---------解説---------
442
+
443
+ ^------------------------------*/
444
+
445
+ .about_bg{
446
+
447
+ background-color: white;
448
+
449
+ }
450
+
451
+ #about{
452
+
453
+ width: 80%;
454
+
455
+ color: black;
456
+
457
+ margin: 0 auto;
458
+
459
+ }
460
+
461
+ .txt_box h2{
462
+
463
+ font-size: 4rem;
464
+
465
+ }
466
+
467
+ .txt_box p{
468
+
469
+ color: black;
470
+
471
+ font-size: 2rem;
472
+
473
+ line-height: 1.7em;
474
+
475
+ }
476
+
477
+ .txt_box,.update{
478
+
479
+ padding:30px 2%;
480
+
481
+ }
482
+
483
+ /*---------更新---------
484
+
485
+ ^------------------------------*/
486
+
487
+
488
+
489
+
490
+
491
+
492
+
493
+ /*---------海の生き物---------
494
+
495
+ ^------------------------------*/
496
+
497
+ #watercreatures{
498
+
499
+ background-image: url(../images//header2.5.jpg);
500
+
501
+ }
502
+
503
+
504
+
505
+ /*---------グッズ*---------
506
+
507
+ ^------------------------------*/
508
+
509
+ #goods{
510
+
511
+ background-image: url(../images/header3.5.jpg);
512
+
513
+ }
514
+
515
+
516
+
517
+
518
+
519
+ /*---------連絡*---------
520
+
521
+ ^------------------------------*/
522
+
523
+
524
+
525
+ コード
526
+
527
+ ```
50
528
 
51
529
  ### 試したこと
52
530
 

1

書式の改善

2020/03/28 01:25

投稿

natsu_kawa
natsu_kawa

スコア15

test CHANGED
File without changes
test CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
 
4
4
 
5
- ### 発生している問題・エラーメッセージ
5
+ ### 発生している問題
6
6
 
7
7
 
8
8
 
9
- ```
9
+
10
10
 
11
11
  スタイルシートを記述しても画像が縮小されず、はみ出してしまう。
12
12
 
13
- ```
13
+
14
14
 
15
15
 
16
16