<!DOCTYPE HTML>
<!--
     Any copyright is dedicated to the Public Domain.
     http://creativecommons.org/publicdomain/zero/1.0/
-->
<html><head>
  <meta charset="utf-8">
  <title>Reference: Masonry layout with multiple `align-tracks` values</title>
  <link rel="author" title="Mats Palmgren" href="mailto:mats@mozilla.com">
<style>
html,body {
  color:black; background-color:white; font:15px/1 "Courier New", monospace; padding:0; margin:0;
}
grid {
  display: inline-grid;
  grid-template-rows: auto;
  grid-template-columns: repeat(8,50px); /*intentionally one more than align-tracks values*/
  gap: 3px 5px;
  padding: 10px 3px 1px 7px;
  border: solid;
  border-width: 1px 7px 3px 5px;
  background: lightgrey content-box;
  height: 500px;
  vertical-align: top;
}
.fallback { grid-template-columns:3px; padding:0; border:0; }
item {
  background: grey;
  height: 2em;
  position: relative;
  border: 1px solid;
}
.purple { background:purple; height:auto; border-top:3px solid; }
z { display: block; background: yellow; height: 0; width:80%; }
a {
 position: absolute;
 inset: 0;
 top: auto;
 border: 2px solid lime;
}
masonry-track {
  display: grid;
  gap: 3px 5px;
}
masonry-track:nth-child(1) { align-content:start }
masonry-track:nth-child(2) { align-content:end }
masonry-track:nth-child(3) { align-content:center }
masonry-track:nth-child(4) { align-content:stretch; grid-template-rows: auto auto repeat(3,max-content) }
masonry-track:nth-child(5) { align-content:space-between }
masonry-track:nth-child(6) { align-content:space-around }
masonry-track:nth-child(7) { align-content:space-evenly }
masonry-track:nth-child(8) { align-content:space-evenly }
</style>
</head>
<body>
<grid>
 <masonry-track>
  <item style="width:25px">1</item>
  <item>11</item>
  <item class="purple">20</item>
  <item class="purple">24</item>
  <item>29</item>
 </masonry-track>
 <masonry-track>
  <item class="purple" style="height:50px">2</item>
  <item class="purple" style="writing-mode:vertical-rl">16 vertical-rl</item>
 </masonry-track>
 <masonry-track>
  <item style="margin-left:5px">3</item>
  <item class="purple">12<z></z></item>
  <item>17</item>
  <item>25</item>
  <item>33</item>
 </masonry-track>
 <masonry-track>
  <item class="purple" style="margin-top:5px">4</item>
  <item class="purple">10</item>
  <item>15</item>
  <item>23</item>
  <item>31</item>
 </masonry-track>
 <masonry-track>
  <item>5</item>
  <item>13</item>
  <item>21</item>
  <item class="purple">28</item>
 </masonry-track>
 <masonry-track>
  <item class="purple">6<a></a></item>
  <item>9<a></a></item>
  <item class="purple">18</item>
  <item class="purple">22</item>
  <item>27</item>
 </masonry-track>
 <masonry-track>
  <item>7</item>
  <item class="purple">14<z></z><a></a></item>
  <item>19</item>
  <item class="purple">26</item>
  <item class="purple">30</item>
 </masonry-track>
 <masonry-track>
  <item class="purple" style="writing-mode:vertical-lr">8 vertical-lr</item>
  <item class="purple">32</item>
 </masonry-track>
</grid>
<grid class="fallback" style="align-content:start">
  <item></item>
</grid>
<grid class="fallback" style="align-content:center">
  <item></item>
</grid>
<grid class="fallback" style="align-content:center">
  <item></item>
</grid>
</body></html>
