Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

252
Visualizações
Fitting a child div inside parent divs fixed size

I have a child div which is a css gird (that is being created by js which will change on users input)that i want to fit 100% according to the parent divs fixed height and width. How do I proceed with this?

.container is the parent div here. I want it to be a fixed size and the .grid-container to fit according to .containers size

var count = 32;
for (var i = 0; i < count; i++) {
  const container = document.querySelector('#grid-container');

  const content = document.createElement('div');
  content.classList.add('grid-item');

  container.appendChild(content);
}
.grid-item {
  background-color: rgb(255, 255, 255);
  border: 1px solid rgba(0, 0, 0, 0.8);
  padding: 20px;
}

.grid-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(auto-fill);
  height: 100%;
}

.container {
  width: 400px;
  height: 400px;
  border: 15px solid green;
}
<div class="container">
  <div class="grid-container" id="grid-container">
  </div>
</div>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If i get you right simple change the container width and/or height values from "fixed" pixels to percents ...

.container{
width: 100%;
height: 100%;
border: 15px solid green;

}

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda