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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:56:49+00:00 2026-05-31T13:56:49+00:00

I created a custom table using div ‘s (was only solution due too complex

  • 0

I created a custom table using div‘s (was only solution due too complex behaviour). But I have a problem with the header and the footer.

The table htmlis basically simple:

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

What I need is the following: when the content inside the table is not too large to be viewed without scrollbar the header will just be at the top and the footer just below the content (so not sticky to the bottom of the container).
But when the content of the table expands (either on page load with new data or by expanding some table content using javascript/jQuery) I need the header to stick at the top of the container and the footer stick at the bottom of the container while the content can scroll without overlapping the header/footer.

I searched around a lot on this but haven’t found a decent solution, is there a way to solve this (as simple as possible) using css and/or javascript/jquery?

Edit
Here a basic sample of what I mean: jsFiddle

If you click the span in the example the header and footer should become fixed at the top and bottom of the container. But how do I detect the increase in size?

  • 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-31T13:56:50+00:00Added an answer on May 31, 2026 at 1:56 pm

    .offset() + .scrollTop() = DISCO

    Basically (jsfiddle demo):

    function placeHeader(){ 
        var $table  = $('#table');  
        var $header = $('#header'); 
        if ($table.offset().top <= $(window).scrollTop()) {
            $header.offset({top: $(window).scrollTop()});
        } else { 
            $header.offset({top: $table.offset().top}); 
        }    
    }
    
    $(window).scroll(placeHeader);
    

    In other words, if the top of the table is above the scrollTop, then position the header at scrollTop, otherwise put it back at the top of the table. Depending on the contents of the rest of the site, you might also need to check if you have scrolled all the way past the table, since then you don’t want the header to stay visible.

    And don’t forget about $(window).height() for doing the same with the footer.

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

Sidebar

Related Questions

I'm using a UITableView to display custom cells created with Interface Builder. The table
I have a custom table created which has a foreign constraint on the core_website
friends, i have created custom title bar using following titlebar.xml file with code <?xml
I am using Symfony 1.4.8 and Propel as ORM. I have created a custom
I have a JTable that is populated using a custom TableModel I created. I
I've a custom table view cell that I created using XIB: I've also linked
We're writing an application for Windows tablet PCs. I have created a custom control
I have created custom MembershipUser, MembershipProvider and RolePrivoder classes. These all work and I
I have created custom posts and I want one page in my site to
I have created custom jQuery UI widget called uiPopover, very similar to UI-dialog (in

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.