Files
shatranj/index.html
2026-01-15 16:06:25 +03:30

79 lines
2.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: Arial, Helvetica, sans-serif;
color: 262942;
}
body {
background-color: #f8e8d3;
}
.title {
font-family: 'Times New Roman', Times, serif;
text-transform: lowercase;
letter-spacing: 0.25rem;
font-size: 4rem;
font-weight: 100;
color: #48517b;
padding: 0 0.5rem 0.5rem 0.5rem;
display: block;
width: min-content;
border-bottom: 2px solid #48517b;
}
header {
display: flex;
padding: 1rem;
justify-content: center;
width: 100vw;
user-select: none;
}
#board {
width: 38rem;
height: 38rem;
display: grid;
grid-template-columns: repeat(8, 1fr);
cursor: not-allowed;
}
.center {
display: flex;
justify-content: center;
}
</style>
</head>
<body>
<header>
<h1 class="title">shatranj</h1>
</header>
<div class="center">
<div id="board">
</div>
</div>
<script>
const container = document.getElementById("board");
const cols = ["A", "B", "C", "D", "E", "F", "G", "H"];
for (let i = 0; i < 64; i++) {
let col = i % 8;
let row = Math.floor(i/8);
const div = document.createElement("div");
div.className = "house";
div.id = cols[col] + (row+1).toString()
if (i % 2 == row % 2) {
div.style.backgroundColor = "#262942"
} else {
div.style.backgroundColor = "#faf5f0"
}
container.appendChild(div);
}
</script>
</body>
</html>