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

回答編集履歴

3

サンプルリンク追加

2020/10/28 04:45

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -38,4 +38,7 @@
38
38
  flex: auto;
39
39
  }
40
40
  }
41
- ```
41
+ ```
42
+ [CodePenサンプル](https://codepen.io/hatena19/pen/pobWyVE?editors=0110)
43
+
44
+ ![イメージ説明](a4183cd6fe470381f0dfa987a119fbbb.gif)

2

コード修正

2020/10/28 04:45

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -8,8 +8,8 @@
8
8
  <p>住んでるところ</p>
9
9
  <p>好きな国</p>
10
10
  </div>
11
- <div class="flex flex-direction-sm gap-10">
11
+ <div class="flex gap-10">
12
- <p>年齢</p>
12
+ <p class="age">年齢</p>
13
13
  <p>好きな食べ物</p>
14
14
  <p>趣味</p>
15
15
  </div>
@@ -22,6 +22,7 @@
22
22
  span {
23
23
  &.flex {
24
24
  display: flex;
25
+ flex-wrap: wrap;
25
26
  }
26
27
  &.flex-direction {
27
28
  flex-direction: column;
@@ -29,11 +30,12 @@
29
30
  &.gridgap-10 {
30
31
  gap: 10px;
31
32
  }
33
+ }
34
+
32
- &.flex-direction-sm {
35
+ .age {
33
- flex-direction: column;
36
+ flex: 0 0 100%;
34
- @media screen and (min-width: 450px) {
37
+ @media screen and (min-width: 450px) {
35
- flex-direction: row;
38
+ flex: auto;
36
- }
37
39
  }
38
40
  }
39
41
  ```

1

質問が変更されたのでコード修正

2020/10/28 04:27

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -1,10 +1,39 @@
1
- 提示のコードだと <div class="flex flex-direction gap-10"> の中身が縦並びだが、
2
- 画面サイズ450px以上の場合は、横並びにしい、ということなら、下記メディアクエリを追加すればいいでしょう
1
+ 質問変更されたのでそれに合わせてコード修正ました
3
2
 
3
+ ```html
4
+ <div class="flex">
5
+ <p>名前</p>
6
+ <div class="flex flex-direction gap-10">
7
+ <div>
8
+ <p>住んでるところ</p>
9
+ <p>好きな国</p>
10
+ </div>
11
+ <div class="flex flex-direction-sm gap-10">
12
+ <p>年齢</p>
13
+ <p>好きな食べ物</p>
14
+ <p>趣味</p>
15
+ </div>
16
+ </div>
17
+ </div>
18
+ ```
19
+
4
- ```css
20
+ ```scss
21
+ div,
5
- @media screen and (min-width: 450px) {
22
+ span {
6
- div.flex-direction {
23
+ &.flex {
7
- flex-direction: row;
24
+ display: flex;
8
25
  }
26
+ &.flex-direction {
27
+ flex-direction: column;
28
+ }
29
+ &.gridgap-10 {
30
+ gap: 10px;
31
+ }
32
+ &.flex-direction-sm {
33
+ flex-direction: column;
34
+ @media screen and (min-width: 450px) {
35
+ flex-direction: row;
36
+ }
37
+ }
9
38
  }
10
39
  ```