Skip to content

Instantly share code, notes, and snippets.

@Hexrays
Last active August 29, 2015 14:22
Show Gist options
  • Save Hexrays/61df9228c09aabe99dee to your computer and use it in GitHub Desktop.
Save Hexrays/61df9228c09aabe99dee to your computer and use it in GitHub Desktop.
Chrome Dev Tools Snippet
function grid(container, columns) {
'use strict';
var els = document.querySelectorAll(container);
[].forEach.call(els, function(el){
var frag = document.createDocumentFragment(),
grid = document.createElement('div'),
cols = columns;
grid.style.position = 'absolute';
grid.style.left = 0;
grid.style.top = 0;
grid.style.width = '100%';
grid.style.height = '100%';
grid.style.borderLeft = '1px solid #3bffff';
grid.style.overflow = 'hidden';
grid.style.pointerEvents = 'none';
frag.appendChild(grid);
for (var i = 0; i < cols; i++) {
var div = document.createElement('div');
// div.style.borderLeft = '1px solid blue';
div.style.borderRight = '1px solid #3bffff';
div.style.width = 100 / columns + '%';
div.style.height = '100%';
div.style.float = 'left';
div.style.boxSizing = 'border-box';
grid.appendChild(div);
}
el.appendChild(frag);
});
}
// grid('.container', 20);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment