function getGrid({ columns, width, widthCol, height, direction, bg, gutter }) {
const root = document.getElementById('root');
const wrapper = document.createElement('div');
wrapper.style.width = width + 'px';
wrapper.style.margin = '0 auto';
wrapper.style.display = 'flex';
wrapper.style.flexDirection = direction;
wrapper.style.columnGap = gutter + 'px';
wrapper.style.position = 'absolute';
wrapper.style.top = '0';
wrapper.style.right = '0';
wrapper.style.bottom = '0';
wrapper.style.left = '0';
wrapper.style.zIndex = 5;
let countW = parseInt(width / gutter);
if (columns === 'auto') {
for (i = 0; i <= countW; i++) {
const colOne = document.createElement('div');
colOne.style.width = widthCol;
colOne.style.height = height;
colOne.style.backgroundColor = bg;
wrapper.appendChild(colOne);
}
}
for (i = 0; i <= columns; i++) {
const colOne = document.createElement('div');
colOne.style.width = widthCol;
colOne.style.height = height;
colOne.style.backgroundColor = bg;
wrapper.appendChild(colOne);
}
root.appendChild(wrapper);
}
function getRows({ columns, width, height, direction, bg, gutter }) {
const root = document.getElementById('root');
const wrapper = document.createElement('div');
wrapper.style.display = 'flex';
wrapper.style.flexDirection = direction;
//wrapper.style.rowGap = gutter + 'px';
const countH = parseInt(window.innerHeight / gutter);
wrapper.style.position = 'relative';
wrapper.style.top = '0';
wrapper.style.right = '0';
wrapper.style.bottom = '0';
wrapper.style.left = '0';
wrapper.style.zIndex = 4;
if (columns === 'auto') {
for (i = 0; i <= 400; i++) {
const rowOne = document.createElement('div');
//rowOne.style.height = '8px';
rowOne.style.boxSizing = 'border-box';
rowOne.style.display = 'flex';
for (j = 0; j <= 400; j++) {
const colOne = document.createElement('div');
colOne.style.height = '8px';
colOne.style.width = '4px';
colOne.style.borderBottom = '0.1px solid rgba(255, 0, 0, 0.1)';
colOne.style.borderRight = '0.1px solid rgba(255, 0, 0, 0.1)';
colOne.style.boxSizing = 'border-box';
//colOne.style.backgroundColor = 'rgba(255, 0, 0, 0.1)';
rowOne.appendChild(colOne);
}
wrapper.appendChild(rowOne);
}
}
root.appendChild(wrapper);
}
getGrid({
columns: 12,
width: 960, //960px | 100%
widthCol: '8.333333%',
height: '100vh', //100vh| 0.1px
direction: 'row',
bg: 'rgba(255, 0, 0, 0.1)',
gutter: 8, //24px | 8px | 4px
});
getRows({
columns: 'auto', //12 | auto
width: '100%', //960px | 100%
height: '0.1px', // 0.1 | 8.333333%
direction: 'column', //row | column
bg: 'rgba(255, 0, 0, 0.1)',
gutter: 8, //24 | 8 | 4px
});