{
  "id": "justified-gallery",
  "name": "Justified Gallery Rows",
  "category": "layouts",
  "tags": [
    "masonry",
    "photo gallery",
    "flex-grow",
    "aspect-ratio",
    "flickr"
  ],
  "description": "A photo gallery where every row fills the width and photos keep their shape, like Flickr or Google Photos.",
  "url": "https://copy-css.com/snippets/justified-gallery",
  "markdown": "https://copy-css.com/snippets/justified-gallery.md",
  "html": "<div class=\"justified\">\n  <div style=\"--r: 1.5\"></div>\n  <div style=\"--r: 0.75\"></div>\n  <div style=\"--r: 1\"></div>\n  <div style=\"--r: 1.33\"></div>\n  <div style=\"--r: 1.78\"></div>\n  <div style=\"--r: 0.8\"></div>\n  <div style=\"--r: 1.2\"></div>\n</div>",
  "css": "/* --r is each photo's width / height ratio */\n.justified {\n  --row-height: 180px;\n  display: flex;\n  flex-wrap: wrap;\n  gap: 8px;\n}\n\n.justified > * {\n  flex: calc(var(--r) * 100) 1 calc(var(--r) * var(--row-height));\n  aspect-ratio: var(--r);\n}\n\n.justified img {\n  display: block;\n  width: 100%;\n  height: 100%;\n  object-fit: cover;\n}\n\n/* Keeps the last row from stretching */\n.justified::after {\n  content: \"\";\n  flex-grow: 1000000;\n}",
  "features": [
    "Flexbox",
    "aspect-ratio",
    "custom properties"
  ],
  "customProperties": [
    {
      "name": "--row-height",
      "value": "180px"
    }
  ]
}
