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-002.html - WPT Dashboard Interop Dashboard
 
 
<!DOCTYPE html>
<html>
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
<link rel="match" href="row-auto-placement-002-ref.html">
<link rel="author" title="Alison Maher" href="mailto:almaher@microsoft.com">
<style>
.masonry {
    display: masonry;
    background: gray;
    item-tolerance: 0;
    grid-template-rows: auto auto auto;
    masonry-direction: row;
    width: 870px;
    padding: 20px;
    gap: 20px;
    font: 15px/1 "Ahem";
}
.masonry > div {
    width: max-content;
}
.auto-item {
    padding: 10px;
}
.auto-item:nth-of-type(1) {
    background: lightskyblue;
}
.auto-item:nth-of-type(2) {
    background: lightcoral;
}
.auto-item:nth-of-type(3) {
    background: lightgreen;
}
.two-track-spanner {
    background: lightpink;
    grid-row: span 2;
    padding: 10px;
}
</style>
<body>
  <p>Test that masonry items with auto placement are correctly positioned within the grid axis.</p>
  <div class="masonry">
    <div class="auto-item">This is some text</div>
    <div class="auto-item">Some larger words in this sentence</div>
    <div class="auto-item">The cat cannot be separated from milk</div>
    <div class="two-track-spanner">The cat still cannot be separated from milk</div>
    <div class="two-track-spanner">The cat still cannot be separated from milk</div>
  </div>
</body>
</html>