Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
CSS grid: element resizes when content is put into in

I am working on a simple tic-tac-toe app with react and I have this problem. When content/text changes inside element it stretches its height, but when all 3 rows have content inside it sets back to normal. Thank you in advance.

link to this project: https://codepen.io/Hakor/pen/LYdorey

my CSS:

.main-container{
    width: 500px;
    height: 500px;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    border: 1px solid black;
}
.square{
    border: 1px solid black;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can try adding an aspect-ratio and maintain the square!

.square{
    border: 1px solid black;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    aspect-ratio: 1;
}

codepen

about 4 years ago · Juan Pablo Isaza Report

0

There are many ways to do this, I would use this one:

.main-container{
    grid-auto-rows: 33%;
}

After that you may set additional 'gap' in .main-container to align your table or 'justify-content'.

Hope this helps! Regards,

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!