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 98221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:09:16+00:00 2026-05-11T00:09:16+00:00

I have a container element which I need to resize as its contents change.

  • 0

I have a container element which I need to resize as its contents change. It contains 2 absolutely positioned divs which can both change height. If I don’t specify the height of the container then anything after the container disappears under the contents.

At the moment I am doing the following but I’d be pleased to find a less laborious alternative:

(container has position:relative, #main and #sidebar are position:absolute, the contents of #sidebar have no positioning specified)

css:

div#mapcontainer { position:relative; width:100%; height: 600px;  } div#main { position:absolute; top: 0; left: 10px; width: 500px; height: 400px; } div#sidebar { position:absolute; top:10px; right:10px; width: 155px; height: 405px;} 

html:

<div id='container'>     <div id='main'>variable height content here</div>     <div id='sidebar'>        <div id='foo'>...</div>        <div id='bar'>....</div>        ...     </div> <div> 

js:

fixHeights = function() {        var children_height = 0;       $('#sidebar'). children().each(function(){children_height += $(this).height();});     $('#container').height(Math.max(children_height, $('#main').height())); }; 
  • 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. 2026-05-11T00:09:17+00:00Added an answer on May 11, 2026 at 12:09 am

    This is a very odd question, as div’s height is always the height of its children.

    Are you floating content in your container div? When you float child content the containing div doesn’t act the same anymore.

    If you’re floating content that extends past the bottom of the container div, add the following div to the very bottom of the children of the container div:

    <div style='clear:both;'></div> 

    That will not allow children to float over it, thus forcing the containing div to be the height of its tallest child…

    <div id='container'>   <div id='dynamic' style='float:left;width:100px;'>dynamic content goes here</div>   <div id='static' style='margin-left:104px;'>Lots of static stuff here</div>   <div style='clear:both;'></div> </div> 

    Okay, I’m not sure why you’re doing the positioning the way you are, but I’ve done something similar for a website that had to look like a desktop application. I don’t believe there is any way to do this other than with javascript. Html documents are designed to flow, not be rigid. If you want to bail on the javascript, you’ll have to let go of the positioning styles and use your floating and clearing divs. Its not that horrible…

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

Sidebar

Ask A Question

Stats

  • Questions 72k
  • Answers 72k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer See the topic 'Using Messages and Message Queues' in MSDN… May 11, 2026 at 1:43 pm
  • added an answer If the array is a specific size and all regular… May 11, 2026 at 1:43 pm
  • added an answer No it is not redundant. 'Save' should be the primary… May 11, 2026 at 1:43 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.