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

320
Views
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 answers
Answer question

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 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!