質問編集履歴

3

コードが微妙にクラス名が違っていたりしたので修正しました

2020/08/04 02:13

投稿

nomura02
nomura02

スコア133

test CHANGED
@@ -1 +1 @@
1
- レスポンシブ対応の各要素の幅指定について(修正版)
1
+ レスポンシブ対応の各要素の幅指定について(修正版2)
test CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  <section class="about container">
24
24
 
25
- <a name="look">
25
+ <a name="look">→これは、上のヘッダー部分でlinkを張っていて、そのリンク先です。
26
26
 
27
27
  <div class="box3">
28
28
 
@@ -206,6 +206,202 @@
206
206
 
207
207
 
208
208
 
209
+ .image_me {
210
+
211
+ width: 100%;
212
+
213
+ }
214
+
215
+
216
+
217
+ @media (max-width: 667px) {
218
+
219
+ .image_me {
220
+
221
+ width: 100%;
222
+
223
+ }
224
+
225
+ }
226
+
227
+ ```
228
+
229
+
230
+
231
+ ### 困ってること
232
+
233
+ .box3はパーセンテージ指定にしたら、うまくレスポンシブしてくれるのですが、
234
+
235
+ 画像の.image_meが極端に小さくなってしまって、ぶかっこうなんです。
236
+
237
+ 親要素をspace-around;にしてみましたが、、これが凶と出ているのか…
238
+
239
+
240
+
241
+ **本当は、.box3と.image_meの間は、20pxくらいの幅にしたい**んですが…うまくいきません。
242
+
243
+ 画像はちっちゃくなるわ、距離感はとりずらいわ、という感じです。
244
+
245
+
246
+
247
+
248
+
249
+ ```CSS
250
+
251
+ .about {
252
+
253
+ width: auto;
254
+
255
+ margin: 0 auto;
256
+
257
+ margin-bottom: 145px;
258
+
259
+ display: -webkit-box;
260
+
261
+ display: -ms-flexbox;
262
+
263
+ display: flex;
264
+
265
+ -ms-flex-pack: distribute;
266
+
267
+ justify-content: space-around;
268
+
269
+ padding: 0 5%;
270
+
271
+ -webkit-box-align: center;
272
+
273
+ -ms-flex-align: center;
274
+
275
+ align-items: center;
276
+
277
+ }
278
+
279
+
280
+
281
+ @media (max-width: 667px) {
282
+
283
+ .about {
284
+
285
+ -webkit-box-orient: vertical;
286
+
287
+ -webkit-box-direction: normal;
288
+
289
+ -ms-flex-direction: column;
290
+
291
+ flex-direction: column;
292
+
293
+ margin-bottom: 130px;
294
+
295
+ padding: 0 15px;
296
+
297
+ }
298
+
299
+ }
300
+
301
+
302
+
303
+ .box3 {
304
+
305
+ border: solid 1px #707070;
306
+
307
+ background-color: #F0F0F0;
308
+
309
+ width: 50%;
310
+
311
+ padding: 40px;
312
+
313
+ }
314
+
315
+
316
+
317
+ @media (max-width: 667px) {
318
+
319
+ .box3 {
320
+
321
+ background-color: #fff;
322
+
323
+ width: auto;
324
+
325
+ border: none;
326
+
327
+ padding: 0;
328
+
329
+ }
330
+
331
+ }
332
+
333
+
334
+
335
+ .box3 h2 {
336
+
337
+ font-size: 64px;
338
+
339
+ margin-bottom: 30px;
340
+
341
+ }
342
+
343
+
344
+
345
+ @media (max-width: 667px) {
346
+
347
+ .box3 h2 {
348
+
349
+ font-size: 38px;
350
+
351
+ }
352
+
353
+ }
354
+
355
+
356
+
357
+ .box3 h3 {
358
+
359
+ font-size: 24px;
360
+
361
+ margin-bottom: 30px;
362
+
363
+ }
364
+
365
+
366
+
367
+ @media (max-width: 667px) {
368
+
369
+ .box3 h3 {
370
+
371
+ font-size: 20px;
372
+
373
+ margin-bottom: 20px;
374
+
375
+ }
376
+
377
+ }
378
+
379
+
380
+
381
+ .box3 p {
382
+
383
+ line-height: 1.8;
384
+
385
+ }
386
+
387
+
388
+
389
+ @media (max-width: 667px) {
390
+
391
+ .box3 p {
392
+
393
+ font-size: 12px;
394
+
395
+ line-height: 1.5;
396
+
397
+ margin-bottom: 30px;
398
+
399
+ }
400
+
401
+ }
402
+
403
+
404
+
209
405
  .image_woman {
210
406
 
211
407
  width: 100%;
@@ -228,202 +424,6 @@
228
424
 
229
425
 
230
426
 
231
- ### 困ってること
232
-
233
- .box3はパーセンテージ指定にしたら、うまくレスポンシブしてくれるのですが、
234
-
235
- 画像の.image_meが極端に小さくなってしまって、ぶかっこうなんです。
236
-
237
- 親要素をspace-around;にしてみましたが、、これが凶と出ているのか…
238
-
239
-
240
-
241
- **本当は、.box3と.image_meの間は、20pxくらいの幅にしたい**んですが…うまくいきません。
242
-
243
- 画像はちっちゃくなるわ、距離感はとりずらいわ、という感じです。
244
-
245
-
246
-
247
-
248
-
249
- ```CSS
250
-
251
- .about {
252
-
253
- width: auto;
254
-
255
- margin: 0 auto;
256
-
257
- margin-bottom: 145px;
258
-
259
- display: -webkit-box;
260
-
261
- display: -ms-flexbox;
262
-
263
- display: flex;
264
-
265
- -ms-flex-pack: distribute;
266
-
267
- justify-content: space-around;
268
-
269
- padding: 0 5%;
270
-
271
- -webkit-box-align: center;
272
-
273
- -ms-flex-align: center;
274
-
275
- align-items: center;
276
-
277
- }
278
-
279
-
280
-
281
- @media (max-width: 667px) {
282
-
283
- .about {
284
-
285
- -webkit-box-orient: vertical;
286
-
287
- -webkit-box-direction: normal;
288
-
289
- -ms-flex-direction: column;
290
-
291
- flex-direction: column;
292
-
293
- margin-bottom: 130px;
294
-
295
- padding: 0 15px;
296
-
297
- }
298
-
299
- }
300
-
301
-
302
-
303
- .box3 {
304
-
305
- border: solid 1px #707070;
306
-
307
- background-color: #F0F0F0;
308
-
309
- width: 50%;
310
-
311
- padding: 40px;
312
-
313
- }
314
-
315
-
316
-
317
- @media (max-width: 667px) {
318
-
319
- .box3 {
320
-
321
- background-color: #fff;
322
-
323
- width: auto;
324
-
325
- border: none;
326
-
327
- padding: 0;
328
-
329
- }
330
-
331
- }
332
-
333
-
334
-
335
- .box3 h2 {
336
-
337
- font-size: 64px;
338
-
339
- margin-bottom: 30px;
340
-
341
- }
342
-
343
-
344
-
345
- @media (max-width: 667px) {
346
-
347
- .box3 h2 {
348
-
349
- font-size: 38px;
350
-
351
- }
352
-
353
- }
354
-
355
-
356
-
357
- .box3 h3 {
358
-
359
- font-size: 24px;
360
-
361
- margin-bottom: 30px;
362
-
363
- }
364
-
365
-
366
-
367
- @media (max-width: 667px) {
368
-
369
- .box3 h3 {
370
-
371
- font-size: 20px;
372
-
373
- margin-bottom: 20px;
374
-
375
- }
376
-
377
- }
378
-
379
-
380
-
381
- .box3 p {
382
-
383
- line-height: 1.8;
384
-
385
- }
386
-
387
-
388
-
389
- @media (max-width: 667px) {
390
-
391
- .box3 p {
392
-
393
- font-size: 12px;
394
-
395
- line-height: 1.5;
396
-
397
- margin-bottom: 30px;
398
-
399
- }
400
-
401
- }
402
-
403
-
404
-
405
- .image_woman {
406
-
407
- width: 100%;
408
-
409
- }
410
-
411
-
412
-
413
- @media (max-width: 667px) {
414
-
415
- .image_woman {
416
-
417
- width: 100%;
418
-
419
- }
420
-
421
- }
422
-
423
- ```
424
-
425
-
426
-
427
427
  何かうまい方法はありませんでしょうか。
428
428
 
429
429
 

2

私が実装したいことを実装している参考URLを記載しました。

2020/08/04 02:12

投稿

nomura02
nomura02

スコア133

test CHANGED
File without changes
test CHANGED
@@ -8,6 +8,10 @@
8
8
 
9
9
  ### やりたいこと:パソコンで徐々に幅を小さくしたときもその動きと連動して徐々に画面に収まってくれるようにしたい。
10
10
 
11
+ https://stand-4u.com/web/javascript/jquery-method.html
12
+
13
+ ↑このページのように、幅をPCで動かしたときも、ちゃんとすべての内容物がおさまってくれるようになっている感じ
14
+
11
15
 
12
16
 
13
17
  ### 実際のコード

1

Sassで書いていたので、コンパイル後のCSSに記載しなおしました!

2020/08/04 01:01

投稿

nomura02
nomura02

スコア133

test CHANGED
@@ -1 +1 @@
1
- レスポンシブ対応の各要素の幅指定について
1
+ レスポンシブ対応の各要素の幅指定について(修正版)
test CHANGED
@@ -54,27 +54,47 @@
54
54
 
55
55
  .about {
56
56
 
57
- width:1000px;
58
-
59
- margin: 0 auto;
60
-
61
- margin-bottom: 145px;
57
+ margin-bottom: 145px;
58
+
62
-
59
+ display: -webkit-box;
60
+
61
+ display: -ms-flexbox;
62
+
63
- display: flex;
63
+ display: flex;
64
+
64
-
65
+ -webkit-box-pack: justify;
66
+
67
+ -ms-flex-pack: justify;
68
+
65
- justify-content: space-between;
69
+ justify-content: space-between;
70
+
66
-
71
+ -webkit-box-align: center;
72
+
73
+ -ms-flex-align: center;
74
+
67
- align-items: center;
75
+ align-items: center;
76
+
68
-
77
+ }
78
+
79
+
80
+
81
+ @media (max-width: 667px) {
82
+
69
- @include sp{
83
+ .about {
84
+
70
-
85
+ -webkit-box-orient: vertical;
86
+
87
+ -webkit-box-direction: normal;
88
+
89
+ -ms-flex-direction: column;
90
+
71
- flex-direction: column;
91
+ flex-direction: column;
72
-
92
+
73
- margin-bottom: 130px;
93
+ margin-bottom: 130px;
74
-
94
+
75
- padding: 0 15px;
95
+ padding: 0 15px;
76
-
96
+
77
- }
97
+ }
78
98
 
79
99
  }
80
100
 
@@ -82,97 +102,121 @@
82
102
 
83
103
  .box3 {
84
104
 
85
- border: solid 1px #707070;
105
+ border: solid 1px #707070;
86
-
106
+
87
- background-color: #F0F0F0;
107
+ background-color: #F0F0F0;
88
-
108
+
89
- width: 315px;
109
+ width: 315px;
90
-
110
+
91
- padding: 40px;
111
+ padding: 40px;
112
+
92
-
113
+ }
114
+
115
+
116
+
117
+ @media (max-width: 667px) {
118
+
93
- @include sp{
119
+ .box3 {
94
-
120
+
95
- background-color: #fff;
121
+ background-color: #fff;
96
-
122
+
97
- width: auto;
123
+ width: auto;
98
-
124
+
99
- border: none;
125
+ border: none;
100
-
126
+
101
- padding: 0;
127
+ padding: 0;
102
-
128
+
103
- }
129
+ }
130
+
104
-
131
+ }
105
-
106
-
132
+
133
+
134
+
107
- h2 {
135
+ .box3 h2 {
108
-
136
+
109
- font-size: 64px;
137
+ font-size: 64px;
138
+
139
+ margin-bottom: 30px;
140
+
141
+ }
142
+
143
+
144
+
145
+ @media (max-width: 667px) {
146
+
147
+ .box3 h2 {
148
+
149
+ font-size: 38px;
150
+
151
+ }
152
+
153
+ }
154
+
155
+
156
+
157
+ .box3 h3 {
158
+
159
+ font-size: 24px;
160
+
161
+ margin-bottom: 30px;
162
+
163
+ }
164
+
165
+
166
+
167
+ @media (max-width: 667px) {
168
+
169
+ .box3 h3 {
170
+
171
+ font-size: 20px;
172
+
173
+ margin-bottom: 20px;
174
+
175
+ }
176
+
177
+ }
178
+
179
+
180
+
181
+ .box3 p {
182
+
183
+ line-height: 1.8;
184
+
185
+ }
186
+
187
+
188
+
189
+ @media (max-width: 667px) {
190
+
191
+ .box3 p {
192
+
193
+ font-size: 12px;
194
+
195
+ line-height: 1.5;
110
196
 
111
197
  margin-bottom: 30px;
112
198
 
113
-
114
-
115
- @include sp{
116
-
117
- font-size: 38px;
118
-
119
- }
199
+ }
120
-
200
+
121
- }
201
+ }
122
-
123
-
124
-
125
- h3 {
202
+
126
-
127
- font-size: 24px;
203
+
128
-
129
- margin-bottom: 30px;
204
+
130
-
131
- @include sp{
205
+ .image_woman {
132
-
206
+
133
- font-size: 20px;
207
+ width: 100%;
134
-
135
- margin-bottom: 20px;
208
+
136
-
137
- }
209
+ }
138
-
139
- }
210
+
140
-
141
-
142
-
143
- p {
211
+
144
-
145
- line-height: 1.8;
212
+
146
-
147
- @include sp{
148
-
149
- font-size: 12px;
150
-
151
- line-height: 1.5;
152
-
153
- margin-bottom: 30px;
213
+ @media (max-width: 667px) {
154
-
155
- }
214
+
156
-
157
- }
158
-
159
- }
160
-
161
-
162
-
163
- .image_me {
215
+ .image_woman {
164
216
 
165
217
  width: 100%;
166
218
 
167
- @include sp{
168
-
169
- width: 100%;
170
-
171
- }
219
+ }
172
-
173
- }
174
-
175
-
176
220
 
177
221
  }
178
222
 
@@ -202,127 +246,175 @@
202
246
 
203
247
  .about {
204
248
 
249
+ width: auto;
250
+
251
+ margin: 0 auto;
252
+
253
+ margin-bottom: 145px;
254
+
255
+ display: -webkit-box;
256
+
257
+ display: -ms-flexbox;
258
+
259
+ display: flex;
260
+
261
+ -ms-flex-pack: distribute;
262
+
263
+ justify-content: space-around;
264
+
265
+ padding: 0 5%;
266
+
267
+ -webkit-box-align: center;
268
+
269
+ -ms-flex-align: center;
270
+
271
+ align-items: center;
272
+
273
+ }
274
+
275
+
276
+
277
+ @media (max-width: 667px) {
278
+
279
+ .about {
280
+
281
+ -webkit-box-orient: vertical;
282
+
283
+ -webkit-box-direction: normal;
284
+
285
+ -ms-flex-direction: column;
286
+
287
+ flex-direction: column;
288
+
289
+ margin-bottom: 130px;
290
+
291
+ padding: 0 15px;
292
+
293
+ }
294
+
295
+ }
296
+
297
+
298
+
299
+ .box3 {
300
+
301
+ border: solid 1px #707070;
302
+
303
+ background-color: #F0F0F0;
304
+
305
+ width: 50%;
306
+
307
+ padding: 40px;
308
+
309
+ }
310
+
311
+
312
+
313
+ @media (max-width: 667px) {
314
+
315
+ .box3 {
316
+
317
+ background-color: #fff;
318
+
205
319
  width: auto;
206
320
 
207
- margin: 0 auto;
208
-
209
- margin-bottom: 145px;
210
-
211
- display: flex;
212
-
213
- justify-content: space-around;
214
-
215
- padding: 0 5%;
216
-
217
- align-items: center;
218
-
219
- @include sp{
220
-
221
- flex-direction: column;
222
-
223
- margin-bottom: 130px;
224
-
225
- padding: 0 15px;
226
-
227
- }
228
-
229
- }
230
-
231
-
232
-
233
- .box3 {
234
-
235
- border: solid 1px #707070;
236
-
237
- background-color: #F0F0F0;
238
-
239
- width: 50%;
240
-
241
- padding: 40px;
242
-
243
- @include sp{
244
-
245
- background-color: #fff;
246
-
247
- width: auto;
248
-
249
- border: none;
250
-
251
- padding: 0;
252
-
253
- }
254
-
255
-
256
-
257
- h2 {
258
-
259
- font-size: 64px;
321
+ border: none;
322
+
323
+ padding: 0;
324
+
325
+ }
326
+
327
+ }
328
+
329
+
330
+
331
+ .box3 h2 {
332
+
333
+ font-size: 64px;
334
+
335
+ margin-bottom: 30px;
336
+
337
+ }
338
+
339
+
340
+
341
+ @media (max-width: 667px) {
342
+
343
+ .box3 h2 {
344
+
345
+ font-size: 38px;
346
+
347
+ }
348
+
349
+ }
350
+
351
+
352
+
353
+ .box3 h3 {
354
+
355
+ font-size: 24px;
356
+
357
+ margin-bottom: 30px;
358
+
359
+ }
360
+
361
+
362
+
363
+ @media (max-width: 667px) {
364
+
365
+ .box3 h3 {
366
+
367
+ font-size: 20px;
368
+
369
+ margin-bottom: 20px;
370
+
371
+ }
372
+
373
+ }
374
+
375
+
376
+
377
+ .box3 p {
378
+
379
+ line-height: 1.8;
380
+
381
+ }
382
+
383
+
384
+
385
+ @media (max-width: 667px) {
386
+
387
+ .box3 p {
388
+
389
+ font-size: 12px;
390
+
391
+ line-height: 1.5;
260
392
 
261
393
  margin-bottom: 30px;
262
394
 
263
-
264
-
265
- @include sp{
266
-
267
- font-size: 38px;
268
-
269
- }
395
+ }
270
-
396
+
271
- }
397
+ }
272
-
273
-
274
-
275
- h3 {
398
+
276
-
277
- font-size: 24px;
399
+
278
-
279
- margin-bottom: 30px;
400
+
280
-
281
- @include sp{
401
+ .image_woman {
282
-
402
+
283
- font-size: 20px;
403
+ width: 100%;
284
-
285
- margin-bottom: 20px;
404
+
286
-
287
- }
405
+ }
288
-
289
- }
406
+
290
-
291
-
292
-
293
- p {
407
+
294
-
295
- line-height: 1.8;
408
+
296
-
297
- @include sp{
298
-
299
- font-size: 12px;
300
-
301
- line-height: 1.5;
302
-
303
- margin-bottom: 30px;
409
+ @media (max-width: 667px) {
304
-
305
- }
410
+
306
-
307
- }
308
-
309
- }
310
-
311
-
312
-
313
- .image_me {
411
+ .image_woman {
314
412
 
315
413
  width: 100%;
316
414
 
317
- @include sp{
318
-
319
- width: 100%;
320
-
321
- }
415
+ }
322
-
416
+
323
- }
417
+ }
324
-
325
-
326
418
 
327
419
  ```
328
420