質問編集履歴
2
モデルサイトのURLを追加しました、JavaScriptのコードはつかっていないです。
title
CHANGED
File without changes
|
body
CHANGED
@@ -182,4 +182,5 @@
|
|
182
182
|
|
183
183
|
コード
|
184
184
|
```
|
185
|
-

|
185
|
+

|
186
|
+
[モデルサイト](http://www.shoeisha.com/book/hp/mcoding/2/)
|
1
htmlのコードとcssのコードを添付しました、画像の写真2枚は src="images/image_L_1.jpg"とsrc="images/image_M_1.jpg"に対応しています。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,12 +1,185 @@
|
|
1
1
|
cssの参考書を2週目しているのですが、内容が少し古いために2週目はなるべく新しい方法を使ってコーディングしています。画像はflexboxを使用していますが右側の余白を埋めるやり方がわかりません。ご教授お願いします。
|
2
2
|
参考書内ではMasonryを導入してレンガ状に並べています。
|
3
|
+
```<body>
|
4
|
+
<div class="flex">
|
5
|
+
<section class="item item-l item-maindish">
|
6
|
+
<a href="">
|
7
|
+
<img class="image" src="images/image_L_1.jpg" alt="">
|
8
|
+
<div class="category">main dish</div>
|
9
|
+
<p class="description">lorem ipsum dolor sit amey,conscrtetir adipisocinf elit,
|
10
|
+
seddoeois,odtempor i</p>
|
11
|
+
</a>
|
12
|
+
</section>
|
13
|
+
<section class="item item-m item-maindish">
|
14
|
+
<a href="">
|
15
|
+
<img class="image" src="images/image_M_1.jpg" alt="">
|
16
|
+
<div class="category">main dish</div>
|
17
|
+
<p class="description">lorem ipsum dolor sit amey,conscrtetir adipisocinf elit,
|
18
|
+
seddoeois,odtempor i</p>
|
19
|
+
</a>
|
20
|
+
</section>
|
21
|
+
<section class="item item-m item-maindish">
|
22
|
+
<a href="">
|
23
|
+
<img class="image" src="images/image_M_2.jpg" alt="">
|
24
|
+
<div class="category">main dish</div>
|
25
|
+
<p class="description">lorem ipsum dolor sit amey,conscrtetir adipisocinf elit,
|
26
|
+
seddoeois,odtempor i</p>
|
27
|
+
</a>
|
28
|
+
</section>
|
29
|
+
<section class="item item-maindish">
|
30
|
+
<a href="">
|
31
|
+
<img class="image" src="images/image_S_1.jpg" alt="">
|
32
|
+
<div class="category">main dish</div>
|
33
|
+
<p class="description">lorem ipsum dolor sit amey,conscrtetir adipisocinf elit,
|
34
|
+
seddoeois,odtempor i</p>
|
35
|
+
</a>
|
36
|
+
</section>
|
37
|
+
<section class="item item-apptizer">
|
38
|
+
<a href="">
|
39
|
+
<img class="image" src="images/image_S_2.jpg" alt="">
|
40
|
+
<div class="category">main dish</div>
|
41
|
+
<p class="description">lorem ipsum dolor sit amey,conscrtetir adipisocinf elit,
|
42
|
+
seddoeois,odtempor incididunt ipo dssd c </p>
|
43
|
+
</a>
|
44
|
+
</section>
|
45
|
+
<section class="item item-column">
|
46
|
+
<a href="">
|
47
|
+
<img class="image" src="images/image_S_3.jpg" alt="">
|
48
|
+
<div class="category">main dish</div>
|
49
|
+
<p class="description">lorem ipsum dolor sit amey,conscrtetir adipisocinf elit,
|
50
|
+
seddoeois,odtempor incididunt ipo</p>
|
51
|
+
</a>
|
52
|
+
</section>
|
53
|
+
<section class="item item-breaktime">
|
54
|
+
<a href="">
|
55
|
+
<img class="image" src="images/image_S_4.jpg" alt="">
|
56
|
+
<div class="category">main dish</div>
|
57
|
+
<p class="description">lorem ipsum dolor sit amey,conscrtetir adipisocinf elit,
|
58
|
+
seddoeois,odtempor</p>
|
59
|
+
</a>
|
60
|
+
</section>
|
61
|
+
<section class="item item-maindish">
|
62
|
+
<a href="">
|
63
|
+
<img class="image" src="images/image_S_5.jpg" alt="">
|
64
|
+
<div class="category">main dish</div>
|
65
|
+
<p class="description">lorem ipsum dolor sit amey,conscrtetir adipisocinf elit,
|
66
|
+
seddoeois,odtempor i</p>
|
67
|
+
</a>
|
68
|
+
</section> <section class="item item-maindish">
|
69
|
+
<a href="">
|
70
|
+
<img class="image" src="images/image_S_6.jpg" alt="">
|
71
|
+
<div class="category">main dish</div>
|
72
|
+
<p class="description">lorem ipsum dolor sit amey,conscrtetir adipisocinf elit,
|
73
|
+
seddoeois,odtempor i</p>
|
74
|
+
</a>
|
75
|
+
</section> <section class="item item-maindish">
|
76
|
+
<a href="">
|
77
|
+
<img class="image" src="images/image_S_7.jpg" alt="">
|
78
|
+
<div class="category">main dish</div>
|
79
|
+
<p class="description">lorem ipsum dolor sit amey,conscrtetir adipisocinf elit,
|
80
|
+
seddoeois,odtempor i</p>
|
81
|
+
</a>
|
82
|
+
</section> <section class="item item-maindish">
|
83
|
+
<a href="">
|
84
|
+
<img class="image" src="images/image_S_8.jpg" alt="">
|
85
|
+
<div class="category">main dish</div>
|
86
|
+
<p class="description">lorem ipsum dolor sit amey,conscrtetir adipisocinf elit,
|
87
|
+
seddoeois,odtempor i</p>
|
88
|
+
</a>
|
89
|
+
</section>
|
90
|
+
</div>
|
91
|
+
</body>
|
92
|
+
|
93
|
+
コード
|
94
|
+
```
|
95
|
+
```
|
96
|
+
html{
|
97
|
+
font-size: 62.5%;
|
98
|
+
}
|
99
|
+
body {
|
100
|
+
padding: 30px;
|
101
|
+
background-color: #f6f7fb;
|
102
|
+
color: #333;
|
103
|
+
font-size: 1.2rem;
|
104
|
+
font-family: "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
|
105
|
+
}
|
106
|
+
*,*::before,*::after{
|
107
|
+
box-sizing: border-box;
|
108
|
+
}
|
109
|
+
a:link,a:visited a:hover,a:active{
|
110
|
+
color:#7c5119;
|
111
|
+
text-decoration: none;
|
112
|
+
}
|
3
|
-
|
113
|
+
.flex{
|
4
114
|
display: flex;
|
5
115
|
align-items: baseline;
|
6
116
|
flex-wrap: wrap;
|
7
117
|
|
8
118
|
}
|
9
119
|
|
120
|
+
.item{
|
121
|
+
margin: 2px;
|
122
|
+
width: 180px;
|
123
|
+
margin-bottom: 4px;
|
124
|
+
padding: 8px;
|
125
|
+
border-bottom: 3px solid;
|
126
|
+
border-radius: 5px;
|
127
|
+
background-color: #fff;
|
128
|
+
}
|
129
|
+
.item .image{
|
130
|
+
display: block;
|
131
|
+
width: 100%;
|
132
|
+
height: 109px;
|
133
|
+
}
|
134
|
+
.item .category{
|
135
|
+
margin: 15px 9px 10px;
|
136
|
+
color:#aaa;
|
137
|
+
letter-spacing: 1px;
|
138
|
+
font-family: "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
|
139
|
+
}
|
140
|
+
.item .category::before{
|
141
|
+
content: '';
|
142
|
+
display: inline-block;
|
143
|
+
width:19px;
|
144
|
+
height: 19px;
|
145
|
+
margin-right: 5px;
|
146
|
+
border:2px solid;
|
147
|
+
border-radius: 50%;
|
148
|
+
vertical-align: -5px;
|
149
|
+
}
|
150
|
+
.item-maindish,
|
151
|
+
.item-maindish .category::before{
|
152
|
+
border-color: #FFC0CB
|
153
|
+
}
|
154
|
+
.item-apptizer,
|
155
|
+
.item-apptizer .category::before{
|
156
|
+
border-color: yellow;
|
157
|
+
}
|
158
|
+
.item>a {
|
159
|
+
display: block;
|
160
|
+
margin:-8px -8px -11px;
|
161
|
+
padding: 8px 8px 11px;
|
162
|
+
border-radius: inherit;
|
163
|
+
color: #777;
|
164
|
+
transition: all 0.3s;
|
165
|
+
}
|
166
|
+
.item a:hover{
|
167
|
+
box-shadow: 0 0 6px -1px rgba(0,0,0,0.3);
|
168
|
+
opacity: 0.8;
|
169
|
+
}
|
170
|
+
.item-m{
|
171
|
+
width:364px;
|
172
|
+
}
|
173
|
+
.item-l{
|
174
|
+
width:732px;
|
175
|
+
}
|
176
|
+
.item-m .image{
|
177
|
+
height: 146px;
|
178
|
+
}
|
179
|
+
.item-l .image{
|
180
|
+
height: 403px;
|
181
|
+
}
|
182
|
+
|
10
183
|
コード
|
11
184
|
```
|
12
185
|

|