Witam, robię grę w kółko i krzyżyk i stylując w css dalej ikona pojawia mi się w lewym górnym rogu pola, wie ktoś czemu?
html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" type="text/css" href="style.css" />
<title>Document</title>
<script src="https://kit.fontawesome.com/4e938b38b8.js" crossorigin="anonymous"></script>
</head>
<body>
<table>
<tr>
<td class='box fa'></td>
<td class='box fa'></td>
<td class='box fa'></td>
</tr>
<tr>
<td class='box fa'></td>
<td class='box fa'></td>
<td class='box fa'></td>
</tr>
<tr>
<td class='box fa'></td>
<td class='box fa'></td>
<td class='box fa'></td>
</tr>
</table>
<script src="app.js"></script>
</body>
</html>
css:
td {
border: 1px solid black;
height: 50px;
width: 50px;
}
.box {
display: flex; justify-content: center; align-items: center;
}
js:
const p1 = 'fa-circle';
const p2 = 'fa-times';
const boxes = [...document.querySelectorAll('td')];
boxes.forEach(box => box.addEventListener('click', take));
function take(e) {
e.target.classList.add(p2);
}