I want to create a 19 * 19 grid. Every grid square is 50px. In this grid odd columns
should have the red background and even columns have green background. How to obtain this?
Here is the code I have written in pen, in this file the grid is like in chess I don’t want it to be like that.
2
Answers
Adding a wrapper for every row seems to be a good way to do this. In that case the grid’s html should look somewhat like this:
Add
display: contents
to the wrapper’s class and the rest of your code will do the job.Here’s the link helped me to find the solution.
Also, here‘s the codepen I’ve edited from yours.
To create a grid of 19 by 19 you can use js to create the cells.
HTML:
** CSS **
** JS **