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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:26:07+00:00 2026-06-01T01:26:07+00:00

Is it possible to simply auto-height a child div to the remaining height not

  • 0

Is it possible to simply auto-height a child div to the remaining height not being used by other component of it’s parent? For the below example, the .body would only be like 20px high, because it’s only using that much for the inner html. Is it possible for the .body to automatically consume the unused height of the .parent? e.g. .parent 200px – .head 30px – .foot 30px = .body 120px?

The sample below will display the .parent yellow box much taller than the used space. If you set .body to “height: 100%”, it’ll use the parent’s height and not respect the .head or .foot elements.

<html>
<head>
<style type="text/css">
.parent {
  width: 200px;
  height: 200px;
  background-color: yellow;
}

.head { height: 30px; background-color: blue; }

.body { background-color: #999; }

.foot { height: 30px; background-color: green; }

</style>
</head>
<body>
<div class="parent">
  <div class="head">I'm the head</div>
  <div class="body">I'm the body</div>
  <div class="foot">I'm the foot</div>
</div>
</body>
</html>

This is only an example. In my project the .parent height can only be reasonably set in the .parent element. Plus the .parent height is essentially dynamically set by the back-end code. The three inner div organization is because the body is collapsible and I have rounded corners for the head and foot.

Any suggestions are well appreciated!

  • 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-06-01T01:26:09+00:00Added an answer on June 1, 2026 at 1:26 am

    This can easily be achieved with negative margins!

    1. Set .body to 100% height
    2. Assuming that the height of .head and .foot is known, you can add a negative top + bottom margin equal to the respective heights of .head and .foot.
    3. Because of the source ordering, the .body will “cover” .head. To counter this, add position: relative to .head.
    4. The inner content of the body need to be shifted down a bit. You cannot add padding to .body directly. Better, add another dive inside .body with padding top + bottom set to desired height.

    Demo here

    Variant of the above example:

    1. Set .body to 100% height
    2. Assuming that the height of .head and .foot is known, you can add a negative bottom margin equal to the sum of heights of .head and .foot.
    3. Since .body will attempt to flow outside the parent, add overflow: hidden to the parent.

    Demo here

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

Sidebar

Related Questions

To phrase my question as simply as possible, is there a way to create
I would simply like to know if it is possible to load tumblr posts
I heard its hard but - possible. I simply want to do it cauz
In InterfaceBuilder, I'm creating the simplest possible UIButton, by simply dragging from the Library
If I try to implement this simple-as-possible example: Update Content with AJAXRefreshRequest it does
Simple problem, though apparently not a simple solution. Example here: http://myhideout.eu/new/ Basically the site
I am working on web application. I wanted to apply auto height to textarea
Possible Duplicate: NullPointerException through auto-boxing-behavior of Java ternary operator The following code uses simple
I'm assuming this is not possible because I got the following error: error C3533:
I have a simple html page with a master div with fixed height (scrollable)

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.