Grid init

This commit is contained in:
Jeremy Thomas
2018-01-30 14:42:17 +00:00
parent 523d9351a6
commit 6d9005ad2a
8 changed files with 975 additions and 1946 deletions

16
docs/_javascript/grid.js Normal file
View File

@@ -0,0 +1,16 @@
document.addEventListener('DOMContentLoaded', () => {
const $cells = getAll('.cell');
$cells.forEach(el => {
const parentWidth = el.parentElement.offsetWidth;
const percentage = el.offsetWidth / parentWidth * 100;
el.append(`${Math.round(percentage)}`);
});
// Functions
function getAll(selector) {
return Array.prototype.slice.call(document.querySelectorAll(selector), 0);
}
});