Add grid
This commit is contained in:
parent
08272480e2
commit
85ef7a2709
2 changed files with 16 additions and 1 deletions
11
script.js
11
script.js
|
|
@ -3,5 +3,14 @@ const conWidth = container.clientWidth;
|
|||
const conHeight = container.clientHeight
|
||||
const grid = document.createElement("div");
|
||||
let numGrid = 16;
|
||||
const gridArea = numGrid ** 2;
|
||||
const gridWidth = conWidth / numGrid;
|
||||
const gridHeight = conHeight / numGrid;
|
||||
const gridHeight = conHeight / numGrid;
|
||||
|
||||
grid.classList.add("grid");
|
||||
grid.style.width = gridWidth + 'px';
|
||||
grid.style.height = gridHeight + 'px';
|
||||
|
||||
for (let i = 0; i < gridArea-1; i++){
|
||||
container.appendChild(grid.cloneNode(true));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,4 +12,10 @@ body{
|
|||
border: 1px solid #eee;
|
||||
height: 500px;
|
||||
width: 500px;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.grid {
|
||||
border: 1px solid #eee;
|
||||
}
|
||||
Loading…
Reference in a new issue