.masonry
- for i in (1..15)
div #{i}
View Compiled
body {
margin: 0;
padding: 1rem;
}
.masonry {
div {
float: left;
width: 150px;
background: #EC985A;
color: white;
margin: 0 0 20px 0;
text-align: center;
font-family: system-ui;
font-weight: 900;
font-size: 2rem;
}
@for $i from 1 through 36 {
div:nth-child(#{$i}) {
$h: (random(400) + 100) + px;
height: $h;
line-height: $h;
}
}
}
View Compiled
document.addEventListener("DOMContentLoaded", function(event) {
var elem = document.querySelector('.masonry');
var msnry = new Masonry( elem, {
// options
itemSelector: 'div',
columnWidth: 170
});
});
This Pen doesn't use any external CSS resources.