Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I vertically align this text in the center of the row?

The children are just <p>X</p>.

I tried with justify-content-center, align-items-center, text-center but it doesn’t work.

I want the text to be in the center of the square vertically and horizontally

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

HTML

<div className="d-flex flex-row justify-content-center boardRow">
   {[...Array(3).keys()].map((col, index_col) => (
      <div 
         className="d-flex flex-column d-flex justify-content-center align-items-center element innerBoard bg-danger">
         {children[row * 3 + col]} 
      </div>
   ))}
</div>

The css:

.boardBox {
  .element {
    border: 1px solid black;
  }

  .boardRow:first-child .element {
    border-top: none;
  }
  .boardRow:last-child .element {
    border-bottom: none;
  }
  .boardRow .element:first-child {
    border-left: none;
  }
  .boardRow .element:last-child {
    border-right: none;
  }
}

.innerBoard {
  width: 20px;
  height: 20px;
}

enter image description here

>Solution :

Based on my comment above, the correct answer in case others face the same issue would be to take care of the margin that usually comes by default for most browsers for the p tags. Remove the p margin and everything should work ok.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading