Files
bulma/docs/_javascript/grid.js

17 lines
412 B
JavaScript
Raw Normal View History

2018-01-30 14:42:17 +00:00
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);
}
});