Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7650869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:21:49+00:00 2026-05-31T11:21:49+00:00

I know there are a hundred and one questions about autosizing a div’s height

  • 0

I know there are a hundred and one questions about autosizing a div’s height but no suggestions seem to work for me which leads me to believe I’m missing something obvious. Basically I have a container Div, then another smaller div inside (absolutely positioned) and in side that one I have X about of div boxes being created (relatively positioned). The problem is that the height of the main container div won’t stretch with it. Any help? Thanks!

.mainContainer{
    position: relative;
    width:800px;
    height:auto;
    padding-top:10px;
    margin-left: auto;
    margin-right: auto;
    border-style:solid;
    border-width:2px;
}
.smallerDivInsideMainDiv{
    position:absolute;
    left: 20px;
    top: 50px;
    width: 600px;
}
.divsThatAreOverflowing{
    position: relative;
    margin-top:20px;
    border-style:solid;
    border-width:1px;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:21:50+00:00Added an answer on May 31, 2026 at 11:21 am

    From what I know, you can’t have an absolutely positioned element inside a relatively positioned element and attempt to have the parent height adjust to the absolute child. If you’re only using it for positioning with left and right, use margins instead.

    <style>
    .mainContainer{
        width: 800px;
        height: auto;
        padding-top: 10px;
        margin-left: auto;
        margin-right: auto;
        border-style: solid;
        border-width: 2px;
        background: #999;
    }
    .smallerDivInsideMainDiv{
        margin-left: 20px;
        margin-top: 50px;
        background: #CCC;
        width: 200px;
    }
    .divsThatAreOverflowing{
        margin-top: 20px;
        border-style: solid;
        border-width: 1px;
        background: red;
        height: 300px;
        width: 100px;
    }​
    </style>
    
    <div class="mainContainer">
        <div class="smallerDivInsideMainDiv">
    <div class="divsThatAreOverflowing"></div>
        </div></div>
    

    enter image description here

    Here the parent is dark grey, and smaller div inside is light grey, with the overflowing div as red. When it changes height, both of it’s containers will adjust.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there is ongoing work for in this regards but what is the
I know this question is asked hundred times. but there is no answer to
I know there is a lot of controversy (maybe not controversy, but arguments at
I know there is a very similar question here but I was hoping to
I know there is a lot of talk about BPM these days and I
I know there is a StringIO stream in Python, but is there such a
I know that there are a lot of discussions already on SO about SOAP,
There are a lot of questions about binding future manipulations to non-existent elements that
I know there are ways, but is there actually a good way? At the
I know there has to be a way: I need help getting any hot

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.