mirror of
https://github.com/jgthms/bulma
synced 2026-03-20 20:24:30 -07:00
Grid init
This commit is contained in:
17
docs/lib/grid.js
Normal file
17
docs/lib/grid.js
Normal file
@@ -0,0 +1,17 @@
|
||||
'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.append('' + Math.round(percentage));
|
||||
});
|
||||
|
||||
// Functions
|
||||
function getAll(selector) {
|
||||
return Array.prototype.slice.call(document.querySelectorAll(selector), 0);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user