Skip to content

Instantly share code, notes, and snippets.

@egardner
Last active November 29, 2016 12:49
Show Gist options
  • Save egardner/901ab27c6c0542b12b52 to your computer and use it in GitHub Desktop.
Save egardner/901ab27c6c0542b12b52 to your computer and use it in GitHub Desktop.
CSS-only masonry grid layout
// Originally adapted from: http://sickdesigner.com/masonry-css-getting-awesome-with-css3/
#grid {
-moz-column-count: 3;
-moz-column-gap: 10px;
-webkit-column-count: 3;
-webkit-column-gap: 10px;
column-count: 3;
column-gap: 10px;
width: 100%;
img {
display: inline-block;
margin-bottom: 0px;
width: 100%;
}
}
@egardner
Copy link
Author

Add in media queries and it's easy to change the number of columns as the viewport resizes for optimal display.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment