
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Lightweight masonry layout
Masonry is great, but it has grown big as it has grown older. Colcade is designed to be small & fast. I recommend using Colcade over Masonry, but read over this feature comparison.
dist
built fileOK | No
#### #### #### | ########## ####
#### #### #### | ########## ####
#### |
#### #### | #### ##########
#### #### #### | #### ##########
#### #### #### | ####
#### |
Download: colcade.js
CDN:
<script src="https://npmcdn.com/colcade@0/colcade.js"></script>
npm: npm install colcade
Bower: bower install colcade
Colcade works by moving item elements into column elements.
<div class="grid">
<!-- columns -->
<div class="grid-col grid-col--1"></div>
<div class="grid-col grid-col--2"></div>
<div class="grid-col grid-col--3"></div>
<div class="grid-col grid-col--4"></div>
<!-- items -->
<div class="grid-item">...</div>
<div class="grid-item">...</div>
<div class="grid-item">...</div>
...
</div>
Sizing of the columns is handled by your own CSS. Change the number of columns by hiding or showing them.
/* Using floats */
.grid-col {
float: left;
width: 50%;
}
/* 2 columns by default, hide columns 2 & 3 */
.grid-col--2, .grid-col--3 { display: none }
/* 3 columns at medium size */
@media ( min-width: 768px ) {
.grid-col { width: 33.333%; }
.grid-col--2 { display: block; } /* show column 2 */
}
/* 4 columns at large size */
@media ( min-width: 1080px ) {
.grid-col { width: 25%; }
.grid-col--3 { display: block; } /* show column 3 */
}
/* with flexbox */
.grid {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
.grid-col {
-webkit-box-flex: 1;
-webkit-flex-grow: 1;
-ms-flex-positive: 1;
flex-grow: 1;
}
/* 2 columns by default, hide columns 2 & 3 */
.grid-col--2, .grid-col--3 { display: none }
/* 3 columns at medium size */
@media ( min-width: 768px ) {
.grid-col--2 { display: block; } /* show column 2 */
}
/* 4 columns at large size */
@media ( min-width: 1080px ) {
.grid-col--3 { display: block; } /* show column 3 */
}
Set selectors for column and item elements in the options.
With jQuery. Edit jQuery demo on CodePen
$('.grid').colcade({
columns: '.grid-col',
items: '.grid-item'
})
With vanilla JS. Edit vanilla JS demo on CodePen
// element as first argument
var grid = document.querySelector('.grid');
var colc = new Colcade( grid, {
columns: '.grid-col',
items: '.grid-item'
});
// selector string as first argument
var colc = new Colcade( '.grid', {
columns: '.grid-col',
items: '.grid-item'
});
With HTML. Edit HTML demo on CodePen
<div class="grid" data-colcade="columns: .grid-col, items: .grid-item">
...
</div>
Add items to end of layout.
// jQuery
$grid.colcade( 'append', items )
// vanilla JS
colc.append( items )
Add items to beginning of layout.
// jQuery
$grid.colcade( 'prepend', items )
// vanilla JS
colc.prepend( items )
Remove Colcade behavior completely.
// jQuery
$grid.colcade('destroy')
// vanilla JS
colc.destroy()
By David DeSandro
MIT License. Have at it.
FAQs
Lightweight masonry layout
The npm package colcade receives a total of 1,821 weekly downloads. As such, colcade popularity was classified as popular.
We found that colcade demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.