I am trying to create a 16x16 grid. Everything works perfectly except that I have some space between my rows, I can't figure out why. The spacing between the columns is perfect but the rows have some gap between them.
Here's my code:
const container = document.getElementById("drawingGrid");
let rows = document.getElementsByClassName("gridRow");
let cells = document.getElementsByClassName("cell");
function createGrid() {
makeRows(16);
makeColumns(16);
}
// create rows
function makeRows(rowNum) {
for (r = 0; r < rowNum; r++) {
let row = document.createElement("div");
container.appendChild(row).className = "gridRow";
}
}
// create columns
function makeColumns(cellNum) {
for (i = 0; i < rows.length; i++) {
for (j = 0; j < cellNum; j++) {
let newCell = document.createElement("div");
rows[j].appendChild(newCell).className = "cell";
}
}
}
createGrid();
.cell {
border: 1px solid gray;
min-width: 10px;
min-height: 10px;
display: inline-block;
margin: 0;
padding: 0;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>EtchASketch</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="drawingGrid">
</div>
<script src="app.js"></script>
</body>
</html>
And here's what it looks like on chrome: