Calculator Tools Calculator Tools
Create

3D Chess Game

Nov 13, 2023

About this app

A simple 3D Chess game, created as a single-page web app.

3D Chess Game ♛ ♚ ♛ ♚

Related apps

Put this on your site

Source

                    <html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">

<title>3D Chess Game</title>
<meta name="description" content="A simple 3D Chess game, created as a single-page web app.">
<meta name="keywords" content="3D, Chess, Game, Web App">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

<script type="text/javascript">
try {
document.addEventListener("DOMContentLoaded", function() {
const board = document.querySelector('.board');
board.addEventListener('click', function(e) {
if (e.target.classList.contains('cell')) {
e.target.classList.toggle('selected');
}
});
});
} catch (error) {
throw error;
}
</script>

<style>
.board {
perspective: 800px;
width: 200px;
height: 200px;
position: relative;
margin: 50px auto;
transform-style: preserve-3d;
}
.cell {
position: absolute;
width: 100px;
height: 100px;
line-height: 100px;
color: white;
text-align: center;
font-size: 3em;
transition: transform 0.5s;
}
.cell:nth-child(even) { background: #775447; }
.cell:nth-child(odd) { background: #edb879; }
.cell:nth-child(1) { transform: rotateX(-90deg) translateY(-100px); transform-origin: top; }
.cell:nth-child(2) { transform: rotateY(90deg) translateZ(-100px); transform-origin: left; }
.cell:nth-child(3) { transform: rotateY(180deg) translateZ(-100px); transform-origin: bottom; }
.cell:nth-child(4) { transform: rotateY(-90deg) translateZ(-100px); transform-origin: right; }
.cell.selected { transform: scale(1.1); }
</style>
</head>
<body>
<div class="container">
<div class="board">
<div class="cell">♛</div>
<div class="cell">♚</div>
<div class="cell">♛</div>
<div class="cell">♚</div>
</div>
</div>
</body>
</html>