CSS is my arch nemesis. I feel like I spend more time trying to fix CSS than I do coding. I’m working on the game of life and am trying to get my cell components to line up in the grid. The code I have right now is pretty basic. For some reason each line of cells has a space above it? I don’t understand where this is coming from.
I assume you are using <div>s to wrap grids into rows of grids—would you happen to have tried line-height: 0 on the wrapper? I had this issue a couple weeks ago when I was working on the Game of Life project and that seems to have done the trick.
I’m actually not wrapping each row. It’s just one long row of divs that are in the grid container. I might try putting each row into its own grid and see if that fixes anything.
You can keep the initial value of inline-block and remove the space between element. Using flexbox or even floating the elements left are great solutions. But it is also a good thing to know why your initial solution was not working and how to fix it. There is a default space between inline or inline-block elements. It is not the browser default space, it is the same space existing between words. In order to remove it, in your case, you can just set the font-size of the parent element( here .default-grid) to zero, and set a standard value to .single-cell font-size. Please refer to this excellent article from CSS-Tricks.