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

質問編集履歴

1

文法の追加

2018/12/21 16:33

投稿

leaf.
leaf.

スコア16

title CHANGED
File without changes
body CHANGED
@@ -8,6 +8,243 @@
8
8
 
9
9
  ##ソースコード
10
10
  [JFiddle](https://jsfiddle.net/h3wr8f04/3/)
11
+ ```html
12
+ <!DOCTYPE html>
13
+ <html lang="ja">
14
+ <head>
15
+ <meta charset="utf-8">
16
+ <meta name="viewport" content="width=device-width,initial-scale=1.0,minium-scale=1.0,user-scalable=no">
17
+ <meta name="description" content="abc">
18
+ <title>aaa</title>
19
+ <link rel="stylesheet" href="css/index.css">
20
+ <link href="https://fonts.googleapis.com/css?family=Viga" rel="stylesheet">
21
+ <link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">
22
+ <link href="https://fonts.googleapis.com/css?family=B612" rel="stylesheet">
23
+ </head>
24
+ <body>
25
+ <!--ヘッダー-->
26
+ <header>
27
+ <p>
28
+ <a href="index.html">aaa</a>
29
+ </p>
30
+ </header>
31
+
32
+ <!--記事-->
33
+ <div>
34
+ <div class="main">
35
+ <ul class="container">
36
+ <li>
37
+ <img src="img/aaa.png">
38
+ <time datetime="2018-12-21">2018年12月21日</time>
39
+ <dl>
40
+ <dt>説明</dt>
41
+ </dl>
42
+ </li>
43
+ <li>
44
+ <img src="img/aaa.png">
45
+ <time datetime="2018-12-21">2018年12月21日</time>
46
+ <dl>
47
+ <dt>説明</dt>
48
+ </dl>
49
+ </li>
50
+ <li>
51
+ <img src="img/aaa.png">
52
+ <time datetime="2018-12-21">2018年12月21日</time>
53
+ <dl>
54
+ <dt>説明</dt>
55
+ </dl>
56
+ </li>
57
+ <li>
58
+ <img src="img/aaa.png">
59
+ <time datetime="2018-12-21">2018年12月21日</time>
60
+ <dl>
61
+ <dt>説明</dt>
62
+ </dl>
63
+ </li>
64
+ <li>
65
+ <img src="img/aaa.png">
66
+ <time datetime="2018-12-21">2018年12月21日</time>
67
+ <dl>
68
+ <dt>説明</dt>
69
+ </dl>
70
+ </li>
71
+ </ul>
72
+ </div>
73
+
74
+ <div class="side">
75
+ <div>
76
+ <h3>CATEGORY</h3>
77
+ <ul>
78
+ <li><a href="#">games</a></li>
79
+ <li><a href="#">foods</a></li>
80
+ <li><a href="#">gadgets</a></li>
81
+ </ul>
82
+ </div>
83
+ </div>
84
+ </div>
85
+ <!--記事-->
86
+ </body>
87
+ </html>
88
+ ```
89
+ ```css
90
+ /*PC*/
91
+ body{
92
+ margin: 0;
93
+ padding: 0;
94
+ background: rgb(234, 237, 242);
95
+ }
96
+ /*ヘッダー*/
97
+ header{
98
+ background: skyblue;
99
+ width: 100%;
100
+ height: 50px;
101
+ display: flex;
102
+ align-items: center;
103
+ justify-content: center;
104
+ }
105
+ header p a{
106
+ text-decoration: none;
107
+ color: white;
108
+ font-size: 190%;
109
+ font-family: 'Viga', sans-serif;
110
+ }
111
+ /*最新記事*/
112
+ .container{
113
+ display: flex;
114
+ list-style: none;
115
+ padding: 0;
116
+ margin: 0 auto;
117
+ padding: 0;
118
+ flex-wrap: wrap;
119
+ justify-content: center;
120
+ width: auto;
121
+ }
122
+ .container img{
123
+ width: 100%;
124
+ height: auto;
125
+ border-top-left-radius: 10px;
126
+ border-top-right-radius: 10px;
127
+ }
128
+ .container li{
129
+ width: 15%;
130
+ margin: 1%;
131
+ box-sizing: border-box;
132
+ padding: 1px;
133
+ background: white;
134
+ border-radius: 10px;
135
+ opacity: 1;
136
+ transition: opacity 1s;
137
+ }
138
+ .container li:hover{
139
+ opacity: 0.5;
140
+ }
141
+ .container li time{
142
+ color: #666;
143
+ font-size: 13px;
144
+ }
145
+ /*float*/
146
+ .main{
147
+ float: left;
148
+ }
149
+ .side{
150
+ float: right;
151
+ background: white;
152
+ width: 300px;
153
+ height: 200px;
154
+ position: relative;
155
+ right: 50px;
156
+ bottom: 150px;
157
+ }
158
+ .side ul li{
159
+ list-style: none;
160
+ }
161
+ .side ul li a{
162
+ text-decoration: none;
163
+ color: #333;
164
+ }
165
+ .side h3{
166
+ background-color: skyblue;
167
+ margin: 0;
168
+ padding: 20px;
169
+ color: white;
170
+ }
171
+ /*レスポンシブ*/
172
+ @media screen and (min-width:0px) and (max-width:480px) {
173
+ header{
174
+ background: skyblue;
175
+ width: 100%;
176
+ height: 100px;
177
+ display: flex;
178
+ align-items: center;
179
+ justify-content: center;
180
+ }
181
+ .container li{
182
+ width: 80%;
183
+ margin: 1%;
184
+ box-sizing: border-box;
185
+ padding: 1px;
186
+ background: white;
187
+ border-radius: 10px;
188
+ opacity: 1;
189
+ transition: opacity 1s;
190
+ }
191
+ .container li dl dt{
192
+ font-size: 90%;
193
+ }
194
+
195
+ }
196
+
197
+ @media screen and (min-width:750px) and (max-width:1000px){
198
+ header{
199
+ background: skyblue;
200
+ width: 100%;
201
+ height: 150px;
202
+ display: flex;
203
+ align-items: center;
204
+ justify-content: center;
205
+ }
206
+ .container li{
207
+ width: 40%;
208
+ margin: 1%;
209
+ box-sizing: border-box;
210
+ padding: 1px;
211
+ background: white;
212
+ border-radius: 10px;
213
+ opacity: 1;
214
+ transition: opacity 1s;
215
+ }
216
+ .container li dl dt{
217
+ font-size: 140%;
218
+ }
219
+ }
220
+ @media screen and (min-width:1001px) and (max-width:1024px){
221
+ header{
222
+ background: skyblue;
223
+ width: 100%;
224
+ height: 150px;
225
+ display: flex;
226
+ align-items: center;
227
+ justify-content: center;
228
+ }
229
+ header p a{
230
+ font-size: 300%;
231
+ }
232
+ .container li{
233
+ width: 40%;
234
+ margin: 1%;
235
+ box-sizing: border-box;
236
+ padding: 1px;
237
+ background: white;
238
+ border-radius: 10px;
239
+ opacity: 1;
240
+ transition: opacity 1s;
241
+ }
242
+ .container li dt{
243
+ font-size: 30px;
244
+ }
245
+ }
246
+
247
+ ```
11
248
  ##やったこと-失敗したこと
12
249
  ``float: rightとleft`` を使ってみたところ、PC用は正常にできたが、スマホ用は下にきたものの中央揃え出来ていなかった。
13
250
  なので``position: relative``とtop,bottom,left,right,などを使ってみたがうまくいかず、サイズが変わったときに対応できなかった。