How to remove outside borders of a 3×3 grid using CSS, e.g. Tic-Tac-Toe UI

I was trying to achieve this kind of UI when I tried implementing the Tic-tac-toe game (I know it looks easy to some XD)
The challenge was how to properly select the first and last column, as well as the first and last row. I seriously did not want to…


This content originally appeared on DEV Community and was authored by Patricia Nicole

I was trying to achieve this kind of UI when I tried implementing the Tic-tac-toe game (I know it looks easy to some XD) Tic-tac-toe board
The challenge was how to properly select the first and last column, as well as the first and last row. I seriously did not want to manually remove the borders of the eight cells.

The data structure of my tic-tac-toe grid is not two-dimensional, but one, so I can easily do the tricks below. Think of my counting as this :
0 | 1 | 2
3 | 4 | 5
6 | 7 | 8

For the first row, the top border should be removed, thus:

.board-item:nth-child(-n + 3) {
    border-top: none;
} 

For the last column,

.board div:nth-child(3n) {
    border-right: none;
}

For the first column,

.board-item:nth-child(3n  - 2) {
    border-left: none;
} 

For the last row,

.board-item:nth-child(n + 7) {
    border-bottom: none;
}

And that is it. Thanks for reading. Check my tic-tac-toe game here.


This content originally appeared on DEV Community and was authored by Patricia Nicole


Print Share Comment Cite Upload Translate Updates
APA

Patricia Nicole | Sciencx (2021-05-25T15:01:43+00:00) How to remove outside borders of a 3×3 grid using CSS, e.g. Tic-Tac-Toe UI. Retrieved from https://www.scien.cx/2021/05/25/how-to-remove-outside-borders-of-a-3x3-grid-using-css-e-g-tic-tac-toe-ui/

MLA
" » How to remove outside borders of a 3×3 grid using CSS, e.g. Tic-Tac-Toe UI." Patricia Nicole | Sciencx - Tuesday May 25, 2021, https://www.scien.cx/2021/05/25/how-to-remove-outside-borders-of-a-3x3-grid-using-css-e-g-tic-tac-toe-ui/
HARVARD
Patricia Nicole | Sciencx Tuesday May 25, 2021 » How to remove outside borders of a 3×3 grid using CSS, e.g. Tic-Tac-Toe UI., viewed ,<https://www.scien.cx/2021/05/25/how-to-remove-outside-borders-of-a-3x3-grid-using-css-e-g-tic-tac-toe-ui/>
VANCOUVER
Patricia Nicole | Sciencx - » How to remove outside borders of a 3×3 grid using CSS, e.g. Tic-Tac-Toe UI. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/25/how-to-remove-outside-borders-of-a-3x3-grid-using-css-e-g-tic-tac-toe-ui/
CHICAGO
" » How to remove outside borders of a 3×3 grid using CSS, e.g. Tic-Tac-Toe UI." Patricia Nicole | Sciencx - Accessed . https://www.scien.cx/2021/05/25/how-to-remove-outside-borders-of-a-3x3-grid-using-css-e-g-tic-tac-toe-ui/
IEEE
" » How to remove outside borders of a 3×3 grid using CSS, e.g. Tic-Tac-Toe UI." Patricia Nicole | Sciencx [Online]. Available: https://www.scien.cx/2021/05/25/how-to-remove-outside-borders-of-a-3x3-grid-using-css-e-g-tic-tac-toe-ui/. [Accessed: ]
rf:citation
» How to remove outside borders of a 3×3 grid using CSS, e.g. Tic-Tac-Toe UI | Patricia Nicole | Sciencx | https://www.scien.cx/2021/05/25/how-to-remove-outside-borders-of-a-3x3-grid-using-css-e-g-tic-tac-toe-ui/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.