0

For my TicTacToe game, I can't center the letter O in the grid container. I tried using just-content: center and text-align: center but nothing is working. How do I fix this? I centered the gameboard inside of the container, and then Inside each game cell I tried to center the content within it, but it is not working.

.container {
  border-style: solid;
  width: 600px;
  height: 600px;
  display: grid;
  background-color: orange;
  text-align: center;
  justify-content: center;
  row-gap: 2px;
  grid-template-rows: 1fr 10fr;
  grid-template-columns: 17fr;
}

.gameboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  row-gap: 15px;
  column-gap: 15px;
  padding: 15px;
}

.gamecell {
  border-style: solid;
  display: flex;
  justify-content: center;
  text-align: center;
}

.cross {
  display: flex;
  justify-content: center;
  text-align: center;
  height: 10px;
  width: 10px;
}
<div class="container">
  <div class="header">
    Tic Tac Toe
  </div>

  <div class="gameboard">
    <div class="gamecell" id="one">
      <div class="cross">O</div>
    </div>
    <div class="gamecell" id="two"></div>
    <div class="gamecell" id="three"></div>
    <div class="gamecell" id="four"></div>
    <div class="gamecell" id="five"></div>
    <div class="gamecell" id="six"></div>
    <div class="gamecell" id="seven"></div>
    <div class="gamecell" id="eight"></div>
    <div class="gamecell" id="nine"></div>
  </div>
</div>
mplungjan
  • 169,008
  • 28
  • 173
  • 236
Adit
  • 1
  • 1
  • You use flex. Have a search for [flex center vertically and horizontally](https://www.google.com/search?q=flex+center+vertically+and+horizontally+site:stackoverflow.com) – mplungjan Sep 18 '21 at 05:58
  • 1
    add `align-items: center;` to your `.gamecell` class – ja408 Sep 18 '21 at 06:00

0 Answers0