回答編集履歴
1
コード追加
answer
CHANGED
@@ -1,5 +1,70 @@
|
|
1
|
+
※修正依頼にもコメントしましたが、コードはマークダウンのコードブロック内にいれてください。
|
2
|
+
|
3
|
+
---
|
4
|
+
|
5
|
+
|
1
6
|
`float:left;` `float:right;` を使って横並びにしてますが、これをやめて、
|
2
7
|
CSS Flexbox か CSS Grid で横ならびレイアウトの実装に変更されることをお勧めします。
|
3
8
|
|
9
|
+
CSS Flexbox のコード例
|
4
10
|
|
11
|
+
```html
|
12
|
+
<div class="box">
|
13
|
+
<div class="box-img">
|
14
|
+
<img src="https://placehold.jp/400x400.png">
|
15
|
+
</div>
|
16
|
+
<div class="text">
|
17
|
+
<h4>1.テキストテキストテキスト</h4><br>
|
5
|
-
|
18
|
+
テキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキスト
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
<div class="box">
|
22
|
+
<div class="box-img">
|
23
|
+
<img src="https://placehold.jp/400x400.png">
|
24
|
+
</div>
|
25
|
+
<div class="text">
|
26
|
+
<h4>2.テキストテキストテキスト</h4><br>
|
27
|
+
テキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキスト
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div class="box">
|
32
|
+
<div class="box-img">
|
33
|
+
<img src="https://placehold.jp/400x400.png">
|
34
|
+
</div>
|
35
|
+
<div class="text">
|
36
|
+
<h4>3.テキストテキストテキスト</h4>
|
37
|
+
テキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキストテキスト
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
```
|
41
|
+
|
42
|
+
```css
|
43
|
+
.box {
|
44
|
+
display: flex;
|
45
|
+
align-items: stretch;
|
46
|
+
height: 400px;
|
47
|
+
}
|
48
|
+
.box:nth-child(2n) {
|
49
|
+
flex-direction: row-reverse;
|
50
|
+
}
|
51
|
+
.text{
|
52
|
+
width: 50%;
|
53
|
+
background-color:#aaa;
|
54
|
+
}
|
55
|
+
|
56
|
+
.box-img{
|
57
|
+
width: 50%;
|
58
|
+
margine:0;
|
59
|
+
padding:0;
|
60
|
+
}
|
61
|
+
|
62
|
+
.box-img img{
|
63
|
+
background-repeat: no-repeat;
|
64
|
+
object-fit: cover;
|
65
|
+
width: 100%;
|
66
|
+
height: 400px;
|
67
|
+
}
|
68
|
+
```
|
69
|
+
|
70
|
+
[Codepenサンプル](https://codepen.io/hatena19/pen/zYGjNye)
|