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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:15:59+00:00 2026-05-23T21:15:59+00:00

I have a CSS layout in which a content div has absolute positioning to

  • 0

I have a CSS layout in which a content div has absolute positioning to be able to scroll the content in case of overflow. This content div is positioned within a relative div, since elements above may differ in height (which is decided by their content).

However, my solution only works in Chrome and IE9, the content div doesn’t show a scrollbar in Firefox. And unfortunately my solution also doesn’t work in older browsers. Do you know a better layout to accomplish the above requirements?

Edit:

The layout should fill the viewport 100% width and 100% height, that’s why I probably need to use tables (please correct me if I’m wrong). Also, I prefer a solution without javascript, since I have other javascripts which could manipulate the contents.

My current code:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Test</title>
    <style type="text/css">
        html, body, form { width:100%; height:100%; margin:0; overflow:hidden; }
    </style>
</head>
<body>
    <table style="width: 100%; height: 100%;">
        <tr>
            <td style="height: 120px; border: 1px solid #000;">
                Top: always same height
            </td>
        </tr>
        <tr style="height: 20px; background-color: Red;">
            <td>
                Variable height: could push the next row down
            </td>
        </tr>
        <tr style="position: relative; overflow: auto;">
            <td style="position: relative; background-color: White; vertical-align: top; overflow: scroll;">
                <div style="position: relative;">
                <div style="position: absolute; bottom: 0; top: 0; left: 0; right: 0; ">
                Content with variable height: needs overflow auto/scroll
                </div>
                </div>
            </td>
        </tr>
    </table>
</body>
</html>
  • 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-23T21:16:00+00:00Added an answer on May 23, 2026 at 9:16 pm

    I can’t figure out how to do it with only css, but I can make it work with javascript.

    HTML (inside body):

    <div id='top'>
        top - fixed height
    </div>
    <div id='middle'>
        middle - some content and stuff
    </div>
    <div id='bottom'>
        bottom - this content should scroll<br/>
        text!<br/>text!<br/>text!<br/>text!<br/>text!<br/>text!<br/>text!<br/>text!<br/>
        text!<br/>text!<br/>text!<br/>text!<br/>text!<br/>text!<br/>text!<br/>text!<br/>
        text!<br/>text!<br/>text!<br/>text!<br/>text!<br/>text!<br/>text!<br/>text!<br/>
    </div>
    

    CSS:

    body{
        margin:0;
        padding:0;
    }
    
    #top{
        width:100%;
        height:100px;
        background:#ccf;
    }
    
    #middle{
        float:left;
        width:100%;
        background:#cfc;
    }
    
    
    #bottom{
        width:100%;
        background:#fcc;
        clear:both;
        overflow:scroll;
        position:fixed;
        bottom:0;
    }
    

    JavaScript (to be placed in head):

    function getDocHeight() {
        var D = document;
        return Math.max(
        Math.max(D.body.scrollHeight, D.documentElement.scrollHeight), Math.max(D.body.offsetHeight, D.documentElement.offsetHeight), Math.max(D.body.clientHeight, D.documentElement.clientHeight));
    }
    
    window.onload = function() {
        document.getElementById('bottom').style.height = getDocHeight() - (100 + document.getElementById('middle').offsetHeight) + "px";
    }
    
    window.onresize=window.onload;
    

    The getDocHeight() function is from here: http://james.padolsey.com/javascript/get-document-height-cross-browser/

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

Sidebar

Related Questions

say I have layout like so: <div id=main> <div id=NormalContent> {some content which is
I have the following DIV layout which translates as little clickable buttons on the
I have a CSS layout as in this picture. I'd like to achieve the
I have a site that has a CSS layout and shouldn't have a scrollbar
I have an annoying CSS layout problem. I'm trying to float images on a
So I've tried to work with the pure-CSS, never-use-tables-for-layout gospel, I really have. But
I have a CSS class called grid which I place on my tables. I
I have a CSS like this ul { list-style-image:url(images/bulletArrow.gif); } ul li { background:
Is it possible to have a CSS rule which basically undoes a prior rule?
I have written a CSS sprite auto-generator which takes selected images out of the

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.