Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
            
- /css/css-grid/masonry/tentative/item-placement/row-auto-placement-001.html - WPT Dashboard Interop Dashboard
 
 
<!DOCTYPE html>
<html>
<link rel="match" href="row-auto-placement-001-ref.html">
<link rel="author" title="Celeste Pan" href="mailto:celestepan@microsoft.com">
<style>
.masonry {
    display: masonry;
    background: gray;
    position: relative;
    item-tolerance: 0;
    masonry-direction: row;
    grid-template-rows: auto auto auto;
    width: 300px;
    padding: 10px;
}
.first-track {
    background: lightskyblue;
    grid-row-start: 1;
}
.second-track {
    background: lightcoral;
    grid-row-start: 2;
}
.third-track {
    background: lightgreen;
    grid-row-start: 3;
}
.square-100x100 {
    width: 100px;
    height: 100px;
}
</style>
<body>
  <p>Test that masonry items with auto placement are correctly positioned when the grid-axis is the block axis. Ensure that margin affects placement.</p>
  <div class="masonry">
    <div class="first-track square-100x100" style="margin-right: 40px;">
      Number 1
    </div>
    <div class="second-track square-100x100" style="margin-bottom: 10px;">
      Number 2
    </div>
    <div class="third-track square-100x100" style="margin-right: 40px;">
      Number 3
    </div>
    <div class="square-100x100" style="background-color: lightpink;">
      Number 4
    </div>
    <div class="square-100x100" style="background-color: lightpink; margin-left: -20px;">
      Number 5
    </div>
    <div style="grid-row: span 2; background: brown; width: 100px;">
      Number 6
    </div>
  </div>
</body>
</html>