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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:27:46+00:00 2026-06-08T19:27:46+00:00

I have a fixed size container with an unknown number of self sizing paragraphs

  • 0

I have a fixed size container with an unknown number of self sizing paragraphs and possibly other elements. I also have a table after that content. I want the table to fill the remaining height of the container.

I have the following HTML:

​<div id="container">
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer mattis. Sed semper dui sed ante. Sed luctus tincidunt nisl. Proin iaculis adipiscing nisl. Class aptent taciti sociosqu ad litora amet.</p>
    <p>Lorem ipsum dolor sit amet, consectetur cras amet.</p>
    <table>
        <thead>
            <tr>
                <th>One</th>
                <th>Two</th>
                <th>Three</th>
                <th>Four</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>111</td>
                <td>222</td>
                <td>33333</td>
                <td>4444</td>
            </tr>
            <tr>
                <td>111</td>
                <td>222</td>
                <td>33333</td>
                <td>4444</td>
            </tr>
            <tr>
                <td>111</td>
                <td>222</td>
                <td>33333</td>
                <td>4444</td>
            </tr>
            <tr>
                <td>111</td>
                <td>222</td>
                <td>33333</td>
                <td>4444</td>
            </tr>
        </tbody>
    </table>
</div>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​

With the following CSS:

#container {
    width: 500px;
    height: 500px;
    background: red;
}

p {
    margin-bottom: 20px;
}

table {
    height: 100%;
    width: 100%;
}

table,
table th,
table td{
    border: 1px solid black;
}

Doing this causes the table to take the height of the container and not just the remaining area. I’ve tried setting the container and the children as table and table-row in CSS and that either causes the other elements to be too large or to loose within their margin.

A fiddle can be found at: http://jsfiddle.net/QLwkU/

I was hoping for a pure CSS solution to this, but I don’t have a problem if it is a reasonable and reusable jQuery solution.

I’ve tried:

var totalHeight = 0;
$('#container').children(':not(table)').each(function(){
    totalHeight += $(this).outerHeight(true);
});
$('#container table').css({'height': ($('#container').outerHeight() - totalHeight)});

But that makes it somewhat more difficult to add a margin to the table if one was needed.

Any thoughts or suggestions would be greatly 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-08T19:27:49+00:00Added an answer on June 8, 2026 at 7:27 pm

    OK, Thanks everyone for the suggestions. For this I’ll just take a slightly modified version to suit my needs a make things a little more dynamic. I added the difference in the outside size and inside size of the table to the calculation just in case a margin is used on the table.

    $('#container table').css('height', (
        $('#container').height() -
        $('#preTableContainer').outerHeight(true) -
        ($('#container table').outerHeight(true) -
         $('#container table').height())
    ));
    

    and the modified css

    #container {
        width: 500px;
        height: 500px;
        background: red;
    }
    
    #preTableContainer {
        overflow: hidden;
    }
    
    p {
        margin-bottom: 20px;
    }
    
    table {
        width: 100%;
        margin-bottom: 20px;
    }
    
    table,
    table th,
    table td{
        border: 1px solid black;
    }
    

    The HTML is the same just with the non table content wrapped in its own div.

    A working fiddle:

    http://jsfiddle.net/QLwkU/10/

    Thanks for all the suggestions. Hopefully the new CSS3 box model will make this an easier process.

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

Sidebar

Related Questions

I have two UILabels, one above the other. The top one has fixed size
I want to make a container of fixed size that will inside have an
Possible Duplicate: Auto-size dynamic text to fill fixed size container. Let's say i have
I have a fixed size layout where I center the content container. I want
I have docbook generated HTML that contains small, fixed size images. All these images
I have a list of thumbnails. They have fixed size. I would like that
The problem: 1) I have buckets of fixed size, in my case 64. This
I have a div with a fixed size of 100px. scrollWidth and scrollHeight works
I have a CDHTMLDialog running in IE that has a fixed size that I
I've an array of fixed size in C . There I might have any

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.