Skip to content

Instantly share code, notes, and snippets.

@bmordan
Last active September 28, 2022 22:28
Show Gist options
  • Select an option

  • Save bmordan/f11331312baaa6d53784c6b7324afab4 to your computer and use it in GitHub Desktop.

Select an option

Save bmordan/f11331312baaa6d53784c6b7324afab4 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tic Tac Toe</title>
<style>
body {
height: 100vh;
width: 100vw;
display: flex;
justify-content: center;
align-content: center;
}
main {
width: 50vw;
height: 50vw;
margin: auto;
display: grid;
grid-template-columns: repeat(3, 16.666vw);
grid-template-rows: repeat(3, 16.666vw);
grid-gap: 2px;
}
section {
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
font-size: 8rem;
display: flex;
justify-content: center;
align-items: center;
background-color: lightblue;
color: hotpink;
}
</style>
</head>
<body>
<main>
<section id="0" onclick="play(0)"></section>
<section id="1" onclick="play(1)"></section>
<section id="2" onclick="play(2)"></section>
<section id="3" onclick="play(3)"></section>
<section id="4" onclick="play(4)"></section>
<section id="5" onclick="play(5)"></section>
<section id="6" onclick="play(6)"></section>
<section id="7" onclick="play(7)"></section>
<section id="8" onclick="play(8)"></section>
</main>
<script>
function play(id) {
const sq = document.getElementById(id)
sq.innerHTML = "X"
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment