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

163
Views
How to get the child width to not exceed the parent's width when parents width did not exceed its max-width value?

The parent div's width did not exceed the value set in its max-width property. How to get child to inherit the actual width of the parent and not cause the parent to increase its width?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I'm sorry but I didn't really understand the question, but I think what you are searching for is this:

.parent-el {
   max-width: 100px;
   width: 50px;
   border: 3px solid black;
}

.child-el {
  height: 100px;
  width: 100%;
  background-color: red;
}
<html>
  <div class="parent-el">
    <div class="child-el"></div>
  </div>
</html>

I set the child's width to 100%. If you set the child's width to 100%, the child's width becomes 100% of the parent's width. For example if the parent's width is 50px and you set the child's width to

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!