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 (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-columns: repeat(2, auto);
column-gap: 10px;
row-gap: 0;
color: #444;
border: 1px solid;
padding: 2px;
}
.column {
display: grid;
grid-template-rows: auto;
gap: 10px;
}
item {
background-color: #444;
color: #fff;
padding: 10px;
margin: 3px;
border: 2px solid blue;
width: 70px;
box-sizing: content-box;
}
</style>
</head>
<body>
<div class="outer-grid">
<div class="column">
<!-- Column 1 -->
<item style="height: 100px;">1</item>
<item style="height: 50px;">3</item>
</div>
<div class="column">
<!-- Column 2 -->
<item style="height: 50px;">2</item>
<item style="height: 100px;">4</item>
</div>
</div>
</body>
</html>