Jump to content

Fixed (table) header & footer, scrollable body.


trq

Recommended Posts

I've got this working perfectly in FF but the footer wont play nice in IE7 (which is my only target, this is an intranet application). The header is also working fine in IE7.

 

Example markup.

 

<div id="actual-list">
  <table>
    <thead>
      <tr>
        <td>Heading</td>
      <tr>
    </thead>
    <tbody>
      <tr>
        <td>Contents</td>
      <tr>
    </tbody>
    <tfoot>
      <tr>
        <td>Footer</td>
      <tr>
    </tfoot>
  </table>
</div>

 

Obviously, I have allot more columns and allot more rows.

 

The relevant CSS.

 

screen.css

#actual-list table{text-align:left;}
#actual-list table thead{background:#70b2e1;font-weight:bold;}
#actual-list table tbody{height:600px;overflow-y:auto;overflow-x:hidden;}/*see ie.css for ie fix*/
#actual-list table tfoot{background:#3383bb;font-weight:bold;}

 

ie.css (loaded only when IE is the client)

#actual-list{position:relative;height:600px;overflow-y:scroll;overflow-x:hidden;}
#actual-list table thead tr{position:absolute;padding:4px;top:expression(this.offsetParent.scrollTop);}
#actual-list table tbody{height:auto;padding:4px;}
#actual-list table tfoot tr{position:absolute;padding:4px;top:expression(this.offsetParent.scrollBottom);}

 

Presently the header is fixed, while both the tbody and tfooter moves when content overflows. I ideally need the footer to stay in a fixed position as well. This is indeed what happens when I use firefox.

Link to comment
Share on other sites

Why are you using a table?

 

Because I have massive amounts of tabular data.

 

Stick the thead, tbody, and tfoot in separate divs. Then use position: fixed;

 

That seems to break the table completely, have you a small example?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.