質問編集履歴

1

muuri.jsのリンクを追加しました。CSSを追加しました。

2022/07/05 02:28

投稿

cocy_eng
cocy_eng

スコア2

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- Muuri.jsを使って画像ギャラリーを表示するサイトを制作しています。Webは少し経験がありますが非専門の者です。
1
+ [Muuri.js](https://muuri.dev/)を使って画像ギャラリーを表示するサイトを制作しています。Webは少し経験がありますが非専門の者です。
2
2
 
3
3
  画面を読み込んだ瞬間に画像レイアウトが崩れてしまい困っています(画像が上に寄って重なってしまっている状態)。
4
4
  要素を全てhtml内にベタ打ちすればこのようにはならないのですが、後々のことを考え、jsonでリスト化した情報をjsでhtmlに書き込む方法を取っています。
@@ -172,3 +172,150 @@
172
172
  {"id":"003","hue":"n","sat":"h","val":"7","caption":"東京都台東区東上野 撮影:iPhone7"}
173
173
  ]
174
174
  ```
175
+ ```css
176
+ *:before, *:after {
177
+ box-sizing: border-box;
178
+ padding: 0;
179
+ margin: 0;
180
+ }
181
+
182
+ body {
183
+ background-color: #eee;
184
+ color: #333;
185
+ text-align: center;
186
+ }
187
+ body a, body a:visited {
188
+ color: #999;
189
+ text-decoration: none;
190
+ }
191
+ body a:hover {
192
+ color: #777;
193
+ }
194
+
195
+ h1 {
196
+ font-size: 36px;
197
+ margin: 40px auto;
198
+ }
199
+
200
+ .filter-controls {
201
+ text-align: center;
202
+ margin-bottom: 30px;
203
+ }
204
+ .filter-controls .control {
205
+ display: inline-block;
206
+ width: 240px;
207
+ margin: 0 10px;
208
+ }
209
+ .filter-controls .control * {
210
+ box-sizing: border-box;
211
+ }
212
+ .filter-controls .control .form-control {
213
+ width: 100%;
214
+ height: 40px;
215
+ padding: 0 20px;
216
+ border: 2px solid #ccc;
217
+ border-radius: 3px;
218
+ background-color: #fff;
219
+ color: #666;
220
+ font-size: 16px;
221
+ cursor: pointer;
222
+ -webkit-appearance: none;
223
+ appearance: none;
224
+ }
225
+ .filter-controls .control .form-control:focus {
226
+ outline: 0;
227
+ border-color: #0CAAF5;
228
+ }
229
+
230
+ .grid {
231
+ position: relative;
232
+ max-width: 90%;
233
+ margin: 0 auto;
234
+
235
+ }
236
+
237
+ .item {
238
+ display: block;
239
+ position: absolute;
240
+ /*width: 33%;/*横並びで3つ表示*/
241
+ width: 24.3%;
242
+ padding:0 5px 10px 5px;/*画像に余白をつける*/
243
+ z-index: 1;
244
+ }
245
+ .item.blue .custom-content {
246
+ border-color: #0CAAF5;
247
+ color: #0CAAF5;
248
+ }
249
+ .item.red .custom-content {
250
+ border-color: #F54487;
251
+ color: #F54487;
252
+ }
253
+ .item.green .custom-content {
254
+ border-color: #00DE73;
255
+ color: #00DE73;
256
+ }
257
+ .item.w2 {
258
+ width: 410px;
259
+ }
260
+ .item.h2 {
261
+ height: 410px;
262
+ }
263
+
264
+ .item-content {
265
+ position: relative;
266
+ width: 100%;
267
+ height: 100%;
268
+ display: table;
269
+ }
270
+ /*画像の横幅を100%にしてレスポンシブ化*/
271
+ .grid img{
272
+ width:100%;
273
+ height:auto;
274
+ vertical-align: bottom;/*画像の下にできる余白を削除*/
275
+ }
276
+
277
+ .custom-content {
278
+ display: table-cell;
279
+ vertical-align: middle;
280
+ text-align: center;
281
+ background: #fff;
282
+ color: #666;
283
+ border: 2px solid;
284
+ border-radius: 3px;
285
+ }
286
+
287
+ .item.muuri-item-dragging {
288
+ z-index: 3;
289
+ transition: none;
290
+ }
291
+
292
+ .item.muuri-item-releasing {
293
+ z-index: 2;
294
+ }
295
+
296
+
297
+ /*横幅が768px以下になった際の指定*/
298
+ @media only screen and (max-width: 1700px) {
299
+ .item {
300
+ width: 23%;/*横並びで4つ表示*/
301
+ padding: 0 5px 10px 5px;
302
+ }
303
+ }
304
+
305
+ /*横幅が768px以下になった際の指定*/
306
+ @media only screen and (max-width: 768px) {
307
+ .item {
308
+ width: 48%;/*横並びで2つ表示*/
309
+ padding: 0 5px 10px 5px;
310
+ }
311
+ }
312
+
313
+ /*===fancyboxサムネイル背景と画像選択時の枠線の指定*/
314
+ .fancybox-thumbs {
315
+ background: transparent!important;
316
+ }
317
+
318
+ .fancybox-thumbs__list a:before {
319
+ border: 6px solid #FA999B;
320
+ }
321
+ ```