mirror of
https://github.com/jgthms/bulma
synced 2026-03-15 02:04:29 -07:00
18 lines
487 B
JavaScript
18 lines
487 B
JavaScript
'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;
|
|
el.innerHTML = '' + percentage.toFixed(2);
|
|
// el.append(`${Math.round(el.offsetWidth)}`);
|
|
});
|
|
|
|
// Functions
|
|
function getAll(selector) {
|
|
return Array.prototype.slice.call(document.querySelectorAll(selector), 0);
|
|
}
|
|
}); |