回答編集履歴

1

コード追加

2020/03/16 01:44

投稿

hatena19
hatena19

スコア33699

test CHANGED
@@ -1,9 +1,139 @@
1
+ ※修正依頼にもコメントしましたが、コードはマークダウンのコードブロック内にいれてください。
2
+
3
+
4
+
5
+ ---
6
+
7
+
8
+
9
+
10
+
1
11
  `float:left;` `float:right;` を使って横並びにしてますが、これをやめて、
2
12
 
3
13
  CSS Flexbox か CSS Grid で横ならびレイアウトの実装に変更されることをお勧めします。
4
14
 
5
15
 
6
16
 
17
+ CSS Flexbox のコード例
7
18
 
8
19
 
20
+
21
+ ```html
22
+
23
+ <div class="box">
24
+
25
+ <div class="box-img">
26
+
27
+ <img src="https://placehold.jp/400x400.png">
28
+
29
+ </div>
30
+
31
+ <div class="text">
32
+
33
+ <h4>1.テキストテキストテキスト</h4><br>
34
+
9
- ※修正依頼にもコメンしましたが、コードはマークダウンのコードブロック内にいれてください。
35
+ テキステキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキスト
36
+
37
+ </div>
38
+
39
+ </div>
40
+
41
+ <div class="box">
42
+
43
+ <div class="box-img">
44
+
45
+ <img src="https://placehold.jp/400x400.png">
46
+
47
+ </div>
48
+
49
+ <div class="text">
50
+
51
+ <h4>2.テキストテキストテキスト</h4><br>
52
+
53
+ テキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキスト
54
+
55
+ </div>
56
+
57
+ </div>
58
+
59
+
60
+
61
+ <div class="box">
62
+
63
+ <div class="box-img">
64
+
65
+ <img src="https://placehold.jp/400x400.png">
66
+
67
+ </div>
68
+
69
+ <div class="text">
70
+
71
+ <h4>3.テキストテキストテキスト</h4>
72
+
73
+ テキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキスト
74
+
75
+ </div>
76
+
77
+ </div>
78
+
79
+ ```
80
+
81
+
82
+
83
+ ```css
84
+
85
+ .box {
86
+
87
+ display: flex;
88
+
89
+ align-items: stretch;
90
+
91
+ height: 400px;
92
+
93
+ }
94
+
95
+ .box:nth-child(2n) {
96
+
97
+ flex-direction: row-reverse;
98
+
99
+ }
100
+
101
+ .text{
102
+
103
+ width: 50%;
104
+
105
+ background-color:#aaa;
106
+
107
+ }
108
+
109
+
110
+
111
+ .box-img{
112
+
113
+ width: 50%;
114
+
115
+ margine:0;
116
+
117
+ padding:0;
118
+
119
+ }
120
+
121
+
122
+
123
+ .box-img img{
124
+
125
+ background-repeat: no-repeat;
126
+
127
+ object-fit: cover;
128
+
129
+ width: 100%;
130
+
131
+ height: 400px;
132
+
133
+ }
134
+
135
+ ```
136
+
137
+
138
+
139
+ [Codepenサンプル](https://codepen.io/hatena19/pen/zYGjNye)