Я хочу сделать приложение для создания схемы рассадки.
Однако проблема в том, что я не могу правильно заказать сиденья, сделанные с Дивом. До того, как я добавил атрибут margin к классу Seat, все выглядело лучше, но как только я это сделал, сиденья начали разделяться.
Вот коды, относящиеся к сиденьям и их контейнеру:
class App {
constructor() {
this.seatMap = new SeatMap(document.getElementById("SeatMapContainer"));
this.seatMap.createSeats(6,6);
}
}
class SeatMap {
constructor(parentElement) {
this.parentElement = parentElement;
this.body = document.createElement("div");
this.body.className = "SeatMap";
this.parentElement.appendChild(this.body);
this.seatList = [];
}
createSeats(row, col) {
this.seatList = [];
for (var a = 0; a < row; a++) {
this.seatList.push([]);
for (var b = 0; b < col; b++) {
this.seatList[a].push(new Seat(this.body));
}
}
}
}
class Seat {
constructor(seatContainer) {
// color, name, and so on.
this.seatContainer = seatContainer;
this.seatBody = document.createElement("div");
this.seatBody.className = "Seat";
this.seatContainer.appendChild(this.seatBody);
console.info("seatcreated");
}
}
var main = new App();#Display {
position: absolute;
top: 50px;
left: 50px;
width: calc(100vw - 50px);
height: calc(100% - 50px);
border: 1px solid black;
box-sizing: border-box;
background-color: white;
z-index: 97;
}
.SeatMap {
position: relative;
width: 100%;
height: 100%;
margin: auto;
margin-top: 50px;
padding: 0;
border: 1px solid black;
columns: 6;
}
.Seat {
position: relative;
margin: 25px;
width: 100px;
height: 60px;
border: 1px solid black;
}<!DOCTYPE html>
<html lang = "ja">
<head>
<meta charset = "utf-8">
<title>Demo</title>
</head>
<body>
<div id = "Display">
<div id = "SeatMapContainer"></div>
</div>
</body>
</html>Как я могу решить эту проблему?



![Безумие обратных вызовов в javascript [JS]](https://i.imgur.com/WsjO6zJb.png)


const nColumns = 6
const nRows = 6
const seatMap = document.createElement('div')
seatMap.style.display = 'grid'
seatMap.style.gridTemplateColumns = `repeat(${nColumns}, 1fr)`
seatMap.style.gap = '10px'
document.body.appendChild(seatMap)
for (let i = 0; i < (nColumns*nRows); i++) {
const seat = document.createElement('div')
seat.style.background = 'orange'
seat.style.aspectRatio = '1/1'
seat.innerText = i
seatMap.appendChild(seat)
}