Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

322
Vistas
How Do I Stop Parent Div From Expanding Because of Its Children?

enter image description here

So child div is has a list of items next to each other, each with a fix width.

In this image child div extends past MainContent but in the actual app, MainContent extends to fit the width of child div.

I would like to make it so that when child overflows, it just has a scroll wheel instead of becoming so large.

I have tried setting Child Div to 'overflow-x : auto'

Child div width is at 100%, as is MainContent.

JSX/HTML

<div className = 'app'>
  <div className = 'navbar'></div>
    <div className = 'maincontent'>
      <div className = 'child'>
        <div className = 'childlist'>
          <button className = 'btn'></button>
          <button className = 'btn'></button>
          <button className = 'btn'></button>
        </div>
      </div>
    </div>
  </div>

CSS

.app : {
    display : flex,
    width: 100vw,
    height :100vh
  }
  .navbar : {
    display : flex,
    flex-direction :column,
    width : 112
  }
  .maincontent:{
    display : flex,
    width : 100%
  }
  .child: {
    width :100%
  }
  .childlist:{
    display : flex,
    width :90%
  }
  .btn:{
    width : 200,
    height :200
  }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

All your containers widths are relative, so it will adjust, not overflow. If your child's width is % of the parent's, then it'll never overflow.

You need to have fixed width to make it overflow.

Plus your code looks really messy, you may want to try Prettier

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda