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

  • Home
  • SEARCH
  • 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 9175365
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:54:03+00:00 2026-06-17T16:54:03+00:00

I have a header div and footer div. The header div never moves; however,

  • 0

I have a header div and footer div. The header div never moves; however, the footer div must stay at the bottom of the window regardless of the screen size, i.e., a “sticky footer.” In between these two divs is a dynamically populated content div.

  1. The bottom of the content div sits directly atop the footer div, and it must move up and down with the footer div (when the screen size vertically expands and contracts.) It too can be considered “sticky.”

  2. However, if there is enough content, the content div must expand vertically (the bottom of the content div still remaining directly atop the footer div) to accommodate as much of the content as possible. This will happen until the top of the content div runs into the header div…

  3. Then, if there is too much content to display between the header and footer divs, the content div will become scrollable, with the height of the content div contracting so as to never overlap with the header div or overlap with the footer div.

  4. And again, the content div can never overlap the header div or the footer div. If there is not enough room between the two divs to display all the content in one view, the content div must become scrollable overflow-y: scroll;.

This explains my (fruitless) attempts so far:
I have yet to successfully accomplish any of this. What I do have is minimal, and, essentially useless. Some of my problems I have are: If I make the footer div position: absolute; bottom: 0px; It will be a “sticky footer” and remain on the bottom of my screen regardless of vertical screen size. However, with this absolute positioning, the content div will happily overlap with the footer. I tried to prevent this by making the content div position: absolute; bottom: 180px;. The 180px is the height of my footer div. This works…a little. It rapidly becomes a problem when content needs to be dynamically added. The top of the content div will quickly overlap with the header div… So then I set a fixed height for the content div, and enable scrolling when it exceeds that height, but that does not take into account a screen larger than my own where there may be more room to display content.

Ultimately, none of this works the way I need it to.
What is the best way to accomplish this using CSS and/or javascript (if required)? And, is there a good starting point to get me on the right track that you may know of?

Thank you for your help!

  • 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-17T16:54:04+00:00Added an answer on June 17, 2026 at 4:54 pm

    I don’t think this is possible in CSS without flexbox. If you’re lucky enough to only have to support browsers that support flexbox (or if you can fall back to the standard layout in older browsers), you can try this:

    HTML:

    <header></header>
    
    <div class="content">
        <div class="container"></div>
    </div>
    
    <footer></footer>
    

    CSS:

    header, footer {
        position: fixed;
        left: 0; right: 0;
        height: 100px;
    }
    
    header { top: 0 }
    footer { bottom: 0 }
    
    .content {
        position: fixed;
        top: 100px; bottom: 100px;
        left: 0; right: 0;
        overflow-y: scroll;
    
        display: -webkit-flex;
        display: -moz-flex;
        display: -o-flex;
        display: flex;
    
        -webkit-align-items: flex-end;
        -moz-align-items: flex-end;
        -o-align-items: flex-end;
        align-items: flex-end;
    }
    

    Here’s the fiddle: http://jsfiddle.net/qhKa9/


    If you have no problem relying on JavaScript, there might be a different solution with far deeper browser support. Here’s a shot at that.

    CSS:

    header, footer {
        position: fixed;
        left: 0; right: 0;
        height: 100px;
    }
    
    header { top: 0 }
    footer { bottom: 0 }
    
    .content {
        position: fixed;
        top: 100px; bottom: 100px;
        left: 0; right: 0;
        overflow-y: scroll;
    }
    
    .container {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
    }
    

    JavaScript (uses jQuery):

    var $content = $('.content'),
        $container = $('.container'),
        containerHeight = $container.outerHeight();
    
    $(window).resize(function () {
        $container.css({
            position: $content.innerHeight() > containerHeight ? 'absolute' : 'static'
        });
    }).resize();
    

    Here’s the fiddle: http://jsfiddle.net/N672c/

    P.S. You should probably throttle that resize event listener, but that’s a discussion for another day.

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

Sidebar

Related Questions

I have newWindow=window.open(document.URL); $('div#header',newWindow.document).hide(); $('div#footer',newWindow.document).hide(); But it doesn't seem to be working. Any ideas?
my site has three div elements, header, content and footer. i have a picture
I would like to have the following kind of HTML: <header></header> <div id='main'></div> <footer></footer>
I have a setup that requires a header div and a footer div to
I have a div (.header) contained within other divs. When my page loads, momentarily
I have a page that consists of a header div for navigation, a content
I have the following structure: <div id=content-header> <h1 id=title>Athletics Calendar</h1> </div> and the following
I have the following three items displayed side by side: <div class=page-header> <h1 style=line-height:0>Title</h1>
I have a div (article) which has two childs (header and #content_outer). Header has
In this html I basically have a sidebar-div and a page-div with the header,

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.