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

回答編集履歴

3

修正

2020/11/10 00:33

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -98,7 +98,7 @@
98
98
  }
99
99
  }
100
100
  ```
101
- [CodePenサンプル](https://codepen.io/pen/?editors=0100)
101
+ [CodePenサンプル](https://codepen.io/hatena19/pen/GRqYoeB?editors=0100)
102
102
 
103
103
  ---
104
104
  HTMLを変更してもいいのなら、CSS Grid を使うとシンプルに実現できます。

2

コード追記

2020/11/10 00:33

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -98,4 +98,96 @@
98
98
  }
99
99
  }
100
100
  ```
101
- [CodePenサンプル](https://codepen.io/pen/?editors=0100)
101
+ [CodePenサンプル](https://codepen.io/pen/?editors=0100)
102
+
103
+ ---
104
+ HTMLを変更してもいいのなら、CSS Grid を使うとシンプルに実現できます。
105
+
106
+ ```html
107
+ <div class="wrapper">
108
+ <div class="header">
109
+ <p>#141f40</p>
110
+ </div>
111
+ <div class="side">
112
+ <p>#80bfa8</p>
113
+ </div>
114
+ <div class="content-left-top">
115
+ <p>#dbd400</p>
116
+ </div>
117
+ <div class="content-left-bottom">
118
+ <p>#0093b7</p>
119
+ </div>
120
+ <div class="content-right">
121
+ <p>#ff9e6b</p>
122
+ </div>
123
+ <div class="content-bottom">
124
+ <p>#8c2727</p>
125
+ </div>
126
+ <div class="footer">
127
+ <p>#d98d30</p>
128
+ </div>
129
+ </div>
130
+ ```
131
+ ```css
132
+ .wrapper {
133
+ width: 400px;
134
+ margin: auto;
135
+ display: grid;
136
+ grid-template-columns: 150px 150px 100px;
137
+ grid-template-rows: 100px 50px repeat(3, 100px);
138
+ }
139
+ .header {
140
+ grid-column: 1/4;
141
+ background-color: #141f40;
142
+ }
143
+ .side {
144
+ grid-row: span 3;
145
+ background-color: #80bfa8;
146
+ }
147
+ .content-left-top {
148
+ background-color: #dbd400;
149
+ }
150
+ .content-left-bottom {
151
+ grid-column: 2;
152
+ background-color: #0093b7;
153
+ }
154
+ .content-right {
155
+ grid-column: 3;
156
+ grid-row: 2/4;
157
+ background-color: #ff9e6b;
158
+ }
159
+ .content-bottom {
160
+ background-color: #8c2727;
161
+ grid-column: 2/4;
162
+ }
163
+ .footer {
164
+ grid-column: 1/4;
165
+ background-color: #d98d30;
166
+ }
167
+ p {
168
+ color:#fff;
169
+ padding:3px;
170
+ font-size:3px;
171
+ }
172
+ @media screen and (max-width: 767px) {
173
+ .wrapper {
174
+ width: 300px;
175
+ grid-template-columns: 100px 125px 75px;
176
+ }
177
+ }
178
+ @media screen and (max-width: 479px) {
179
+ .wrapper {
180
+ width: 150px;
181
+ grid-template-columns: 150px;
182
+ grid-template-rows: repeat(3, 100px) 50px repeat(3, 100px);
183
+ }
184
+ .wrapper > div {
185
+ grid-column: 1;
186
+ grid-row: span 1;
187
+ }
188
+ .wrapper > .content-right {
189
+ grid-row: 3;
190
+ }
191
+ }
192
+ ```
193
+ [CodePenサンプル](https://codepen.io/hatena19/pen/XWKxdmp?editors=1100)

1

コード修正

2020/11/08 21:51

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -79,12 +79,9 @@
79
79
  }
80
80
 
81
81
  @media screen and (max-width: 479px) {
82
- .wrapper{
82
+ .wrapper, .wrapper * {
83
83
  width: 150px;
84
84
  }
85
- .wrapper * {
86
- width: 150px;
87
- }
88
85
  .main, .content {
89
86
  height: 100%;
90
87
  }
@@ -96,9 +93,7 @@
96
93
  flex-direction: column-reverse;
97
94
  }
98
95
  .side,
99
- .top-left-bottom,
100
- .content-top-right,
96
+ .content-top-right {
101
- .top-right {
102
97
  height: 100px;
103
98
  }
104
99
  }