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

回答編集履歴

1

修正

2020/05/10 01:47

投稿

new1ro
new1ro

スコア4528

answer CHANGED
@@ -1,3 +1,75 @@
1
+ 追記しました。文字で縦方向に伸びてしまう要素にposition: absolute;が指定されているのが問題です。
2
+ なので
3
+ .blue、.greenにposition: relative;を指定し、背景の.redと.yellowにはposition: absolute;を指定するようにしています。
4
+
5
+ ```CSS
6
+ .aa {
7
+ height: 300px;
8
+ }
9
+ .content {
10
+ position: relative;
11
+ }
12
+
13
+ .inner {
14
+ width: 1100px;
15
+ margin: 0 auto;
16
+
17
+ /* 追加 */
18
+ max-width: 100%;
19
+ position: relative;
20
+ z-index: 1000;
21
+ }
22
+
23
+ .blue {
24
+ background-color: blue;
25
+ min-height: 100px;
26
+ /* position: absolute; */
27
+ position: relative;
28
+ top: -50px;
29
+
30
+ /* 追加 */
31
+ z-index: 1000;
32
+ }
33
+ .red {
34
+ background-color: red;
35
+ height: 200px;
36
+
37
+ /* 追加 */
38
+ position: absolute;
39
+ top: 0;
40
+ left: 0;
41
+ width: 100%;
42
+ height: 100%;
43
+ }
44
+
45
+ .text {
46
+ width: 90%;
47
+ }
48
+
49
+ .green {
50
+ background-color: green;
51
+ min-height: 100px;
52
+ /* position: absolute; */
53
+ position: relative;
54
+ top: -50px;
55
+
56
+ /* 追加 */
57
+ z-index: 1000;
58
+ }
59
+ .yellow {
60
+ background-color: yellow;
61
+ height: 200px;
62
+
63
+ /* 追加 */
64
+ position: absolute;
65
+ top: 0;
66
+ left: 0;
67
+ width: 100%;
68
+ height: 100%;
69
+ }
70
+ ```
71
+
72
+ ---
1
73
  `min-height`を使うといかがでしょうか?
2
74
 
3
75
  ```CSS