Files
bulma/docs/_javascript/grid.js
Jeremy Thomas fddb98d732 More grid work
2018-02-13 09:38:04 +00:00

18 lines
468 B
JavaScript

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