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

228
Visualizações
How to set single value to height/width of whatever minimum value of it's parent height/width by CSS

I am working on meet conference and for that there are multiple tiles like we saw in google meet have contains avatar (middle in tile). As per the height and width changes in tile (#parent) also get change in avatar (#child) height and width. After getting minimum value of parent height and width we need to set this value to child height and width. For more clearance have some expected screenshorts.

case 1 : parent height=350 width=340 || min(350, 340)
         child height/width should be = 340
case 2 : parent height=340 width=100 || min(340, 100)
         child height/width should be = 100
case 3 : parent height=120 width=330 || min(120, 330)
         child height/width should be = 120

should adjustable as resize.

please check this expected outcome screenshort

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

0

Not 100% sure what you're asking. Will something like this work?

const child = document.querySelector("#child")
const parent = child.parentElement

child.style.height = `${parent.offsetHeight/2}px`
child.style.width = `${parent.offsetWidth/2}px`
#parent{
 height: 50vh;
 width: 50vw;
 background-color: beige;
 display: flex;
justify-content: center;
align-items: center;
}
#child{
display: flex;
justify-content: center;
align-items: center;
background-color: pink;
}
<div id="parent">
 <div id="child">Child</div>
</div>

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