Files
bulma/docs/lib/grid.js

18 lines
487 B
JavaScript
Raw Permalink Normal View History

2018-01-30 14:42:17 +00:00
'use strict';
document.addEventListener('DOMContentLoaded', function () {
var $cells = getAll('.cell');
$cells.forEach(function (el) {
var parentWidth = el.parentElement.offsetWidth;
var percentage = el.offsetWidth / parentWidth * 100;
2018-02-13 09:38:04 +00:00
el.innerHTML = '' + percentage.toFixed(2);
// el.append(`${Math.round(el.offsetWidth)}`);
2018-01-30 14:42:17 +00:00
});
// Functions
function getAll(selector) {
return Array.prototype.slice.call(document.querySelectorAll(selector), 0);
}
});