I've put together a board for Ultimate Tic-Tac-Toe (What's that?). This is part of the current code-challenge: Code a Ultimate Tic-Tac-Toe
Resources:
- Live demo of my view – For you to see what I did there
- Simon's working implementation – To illustrate that this is going to be a functional game
Questions:
- What are your thoughts on the Markup? Overkill? Just right?
- What would you improve on the CSS side? Especially asking in the direction of absolute dimensions and borders.
HTML:
<div class="game">
<div class="area area-0-0">
<div class="tile tile-0-0">
<button type="button" class="tile-button"></button>
</div>
<div class="tile tile-1-0">
<button type="button" class="tile-button"></button>
</div>
<div class="tile tile-2-0">
<button type="button" class="tile-button"></button>
</div>
<div class="tile tile-0-1">
<button type="button" class="tile-button"></button>
</div>
<div class="tile tile-1-1">
<button type="button" class="tile-button"></button>
</div>
<div class="tile tile-2-1">
<button type="button" class="tile-button"></button>
</div>
<div class="tile tile-0-2">
<button type="button" class="tile-button"></button>
</div>
<div class="tile tile-1-2">
<button type="button" class="tile-button"></button>
</div>
<div class="tile tile-2-2">
<button type="button" class="tile-button"></button>
</div>
</div>
<div class="area area-1-0">
<!-- 9 tiles -->
</div>
<div class="area area-2-0">
<!-- 9 tiles -->
</div>
<div class="area area-0-1">
<!-- 9 tiles -->
</div>
<div class="area area-1-1">
<!-- 9 tiles -->
</div>
<div class="area area-2-1">
<!-- 9 tiles -->
</div>
<div class="area area-0-2">
<!-- 9 tiles -->
</div>
<div class="area area-1-2">
<!-- 9 tiles -->
</div>
<div class="area area-2-2">
<!-- 9 tiles -->
</div>
</div>
CSS:
*, *:before, *:after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
margin: 0;
}
/*
* GAME
* Board size is calculated as follows:
*
* .game = .area * 3
* 459px = 153px * 3
*
* .area = padding-left + .tile * 3 + padding-right + border
* 153px = 3px + 48px * 3 + 3px + 3px
*
* .tile = padding-left + .width + padding-right
* 48px = 3px + 42px + 3px
*/
.game {
width: 459px;
margin-top: 50px;
margin-right: auto;
margin-left: auto;
}
/* Clearfixing .game */
.game:after {
content: "";
display: table;
clear: both;
}
@media screen and (max-width: 500px) {
.game {
width: 315px;
}
}
/*
* AREA
*/
.area {
float: left;
width: 153px;
padding: 3px;
}
.area:nth-child(3n-1),
.area:nth-child(3n-0) {
border-left: 3px solid #444;
}
.area:nth-child(4),
.area:nth-child(5),
.area:nth-child(6),
.area:nth-child(7),
.area:nth-child(8),
.area:nth-child(9) {
border-top: 3px solid #444;
}
/* Clearfixing .area */
.area:after {
content: "";
display: table;
clear: both;
}
@media screen and (max-width: 500px) {
.area {
width: 105px;
}
}
/*
* TILE
*/
.tile {
float: left;
padding: 3px;
}
/*
* BUTTONS
*/
.tile-button {
width: 42px;
height: 42px;
padding: 0;
cursor: pointer;
vertical-align: middle;
border: 1px solid gray;
border-radius: 3px;
background-color: greenYellow;
}
@media screen and (max-width: 500px) {
.tile-button {
width: 26px;
height: 26px;
}
}
.tile-button:hover,
.tile-button:focus {
border-color: #444;
background-color: yellowGreen;
}