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

178
Visualizações
how to increase the size of a div with a list based on the number of elements in the list

index.html

<div class="list">
    <ul>
      <li>item1</li>
      <li>item2</li>
      <li>item3</li>
    </ul>
  </div>

style.css

.list {
    display: flex;
    flex-direction: column;
    max-height: 200px !important;
    overflow: auto;
    min-height : 115px;
}

in the above code the number of li items inside ul tag may vary so I want to keep the height for the div only that will be needed for the li tags to be displayed completely how to change the height dynamically based on the number of li elements and the space they occupy

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

0

Try adding max-height to the css of the class you are using.

    .list {
    display: flex;
    flex-direction: column;
    max-height: 200px !important;
    overflow: auto;
    min-height : 115px;
    max-height: 100%;
    }
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