mirror of
https://github.com/jgthms/bulma
synced 2026-03-15 02:04:29 -07:00
Grid init
This commit is contained in:
16
docs/_javascript/grid.js
Normal file
16
docs/_javascript/grid.js
Normal 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);
|
||||
}
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user