Source code
Revision control
Copy as Markdown
Other Tools
<!DOCTYPE HTML>
<html><head>
<meta charset="utf-8">
<title>CSS Grid Test: Masonry layout with item-tolerance: infinite (row direction - reference)</title>
<style>
html,body {
color:black; background-color:white; font:16px/1 monospace; padding:0; margin:0;
}
.outer-grid {
display: inline-grid;
grid-template-rows: repeat(2, auto);
row-gap: 10px;
column-gap: 0;
color: #444;
border: 1px solid;
padding: 2px;
}
.row {
display: grid;
grid-auto-flow: column;
grid-auto-columns: auto;
gap: 10px;
}
item {
background-color: #444;
color: #fff;
padding: 10px;
margin: 3px;
border: 2px solid blue;
height: 70px;
box-sizing: content-box;
}
</style>
</head>
<body>
<div class="outer-grid">
<div class="row">
<!-- Row 1 -->
<item style="width: 100px;">1</item>
<item style="width: 50px;">3</item>
</div>
<div class="row">
<!-- Row 2 -->
<item style="width: 50px;">2</item>
<item style="width: 100px;">4</item>
</div>
</div>
</body>
</html>