Create Tic-Tac-Toe in HTML/CSS. Understand layers (z-index).

This commit is contained in:
2019-07-21 21:39:18 -04:00
parent d18487c306
commit 60ee0dd172
4 changed files with 129 additions and 5 deletions

81
tictactoe.css Normal file
View File

@@ -0,0 +1,81 @@
body {
text-align: center;
margin: 0;
}
.tic-tac-toe {
height: 450px;
width: 450px;
margin: 50px auto 30px auto;
position: relative;
background-color: #E6E6FA;
}
.tic-tac-toe input[type="radio"] {
display: none;
}
.tic-tac-toe input[type="radio"].turn-1 + label {
z-index: 1;
display: block;
}
.tic-tac-toe input[type="radio"].turn-1:checked + label {
cursor: default;
background-color: red;
z-index: 10 !important;
}
.tic-tac-toe input[type="radio"].turn-1.field-9:checked ~ .turn-2.field-3 + label {
display: block;
cursor: default;
background-color: green;
z-index: 2;
}
.tic-tac-toe label {
background-color: #78bec5;
height: 140px;
width: 140px;
display: none;
margin: 5px;
position: absolute;
cursor: pointer;
color: #fff;
-moz-transition: background-color 0.3s;
-o-transition: background-color 0.3s;
-webkit-transition: background-color 0.3s;
transition: background-color 0.3s;
}
.tic-tac-toe input[type="radio"].left + label {
left: 0px;
right: 300px;
}
.tic-tac-toe input[type="radio"].middle + label {
left: 150px;
right: 150px;
}
.tic-tac-toe input[type="radio"].right + label {
left: 300px;
right: 0px;
}
.tic-tac-toe input[type="radio"].top + label {
top: 0px;
bottom: 300px;
}
.tic-tac-toe input[type="radio"].center + label {
top: 150px;
bottom: 150px;
}
.tic-tac-toe input[type="radio"].bottom + label {
top: 300px;
bottom: 0px;
}