views:

23

answers:

2

Hi all,

Basically, what I would like is a fixed header, frozen pane, table, such as, http://www.cssplay.co.uk/menu/tablescroll.html. However, his tables have one key weakness. The header will not scroll horizontally with a body.

Here is a sample, based off the link above. However, the header clearly does not scroll left and right with the body of the table.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <style type="text/css">
            .outer
            {
                position:relative;
                padding-top: 50px;
                border: 1px solid #0000ff;
            }
            .innera
            {
                overflow:auto;
                height: 100px;
                border: 1px solid #00ff00;
            }
            .outer thead tr
            {
                position:absolute;
                top: 0px;
                left:0;
            }
            .outer th, .outer td
            {
                text-align:left;
                white-space:nowrap;
            }
        </style>
    </head>
    <body>
        <div class="outer">
            <div class="innera">
                <table >
                    <thead>
                        <tr>
                            <th scope="col">FLIGHT CODE</th>
                            <th scope="col">FROM</th>
                            <th scope="col">STA</th>
                            <th scope="col">ETA</th>
                            <th scope="col" class="nd">Notes</th>
                        </tr>
                    </thead>

                    <tfoot>
                        <tr>
                            <td colspan="5">DATE : 19th OCTOBER 2005</td>
                        </tr>
                    </tfoot>

                    <tbody>
                        <tr>
                            <th scope="row">T3 4264</th>
                            <td>ISLE OF MAN</td>
                            <td>11:40</td>
                            <td>11:42</td>
                            <td>LANDED AT 11:43</td>
                        </tr>

                        <tr class="dk">
                            <th scope="row">BA 4081</th>
                            <td>PARIS-CDG</td>
                            <td>11:45</td>
                            <td>11:57</td>
                            <td>LANDED AT 11:58</td>
                        </tr>
                        <tr>
                            <th scope="row">BE 843</th>
                            <td>BELFAST CITY</td>
                            <td>11:45</td>
                            <td>11:40</td>
                            <td>LANDED AT 11:41</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">GR 642</th>
                            <td>GUERNSEY</td>
                            <td>11:55</td>
                            <td>11:38</td>
                            <td>LANDED AT 11:37</td>
                        </tr>
                        <tr>
                            <th scope="row">EZY 6192</th>
                            <td>PISA</td>
                            <td>12:05</td>
                            <td>12:18</td>
                            <td>LANDED AT 12:17</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">EZY 6052</th>
                            <td>MALAGA</td>
                            <td>12:15</td>
                            <td>11:55</td>
                            <td>LANDED AT 11:55</td>
                        </tr>
                        <tr>
                            <th scope="row">EZY 6074</th>
                            <td>ALICANTE</td>
                            <td>12:35</td>
                            <td>12:12</td>
                            <td>LANDED AT 12:14</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">EZY 6068</th>
                            <td>VALENCIA</td>
                            <td>12:40</td>
                            <td>12:49</td>
                            <td>LANDED AT 12:48</td>
                        </tr>
                        <tr>
                            <th scope="row">BA 4023</th>
                            <td>GLASGOW</td>
                            <td>12:50</td>
                            <td>12:41</td>
                            <td>LANDED AT 14:08</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">FR 506</th>
                            <td>DUBLIN</td>
                            <td>13:00</td>
                            <td>12:52</td>
                            <td>LANDED AT 12:51</td>
                        </tr>
                        <tr>
                            <th scope="row">EZY 6046</th>
                            <td>PALMA</td>
                            <td>13:20</td>
                            <td>16:31</td>
                            <td>LANDED AT 16:31</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">EI 286</th>
                            <td>DUBLIN</td>
                            <td>13:40</td>
                            <td>13:33</td>
                            <td>LANDED AT 13:32</td>
                        </tr>
                        <tr>
                            <th scope="row">EZY 6096</th>
                            <td>BUDAPEST</td>
                            <td>13:40</td>
                            <td>13:38</td>
                            <td>LANDED AT 13:40</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">BE 152</th>
                            <td>JERSEY</td>
                            <td>13:50</td>
                            <td>13:36</td>
                            <td>LANDED AT 13:38</td>
                        </tr>
                        <tr>
                            <th scope="row">BA 4122</th>
                            <td>ZURICH</td>
                            <td>13:55</td>
                            <td>13:31</td>
                            <td>LANDED AT 13:31</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">T3 4505</th>
                            <td>ABERDEEN</td>
                            <td>14:10</td>
                            <td>14:19</td>
                            <td>LANDED AT 14:18</td>
                        </tr>
                        <tr>
                            <th scope="row">WOW 304</th>
                            <td>JERSEY</td>
                            <td>14:10</td>
                            <td>13:47</td>
                            <td>LANDED AT 13:48</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">EZY 4565</th>
                            <td>BERLIN-SCHOF</td>
                            <td>14:50</td>
                            <td>14:54</td>
                            <td>LANDED AT 14:55</td>
                        </tr>
                        <tr>
                            <th scope="row">BA 4085</th>
                            <td>PARIS-CDG</td>
                            <td>14:55</td>
                            <td>14:42</td>
                            <td>LANDED AT 14:43</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">EZY 6116</th>
                            <td>NICE</td>
                            <td>15:15</td>
                            <td>18:22</td>
                            <td>LANDED AT 18:21</td>
                        </tr>
                        <tr>
                            <th scope="row">KL 1053</th>
                            <td>AMSTERDAM</td>
                            <td>15:15</td>
                            <td>14:57</td>
                            <td>LANDED AT 14:57</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">BA 4039</th>
                            <td>EDINBURGH</td>
                            <td>15:25</td>
                            <td>15:28</td>
                            <td>LANDED AT 15:29</td>
                        </tr>
                        <tr>
                            <th scope="row">EZY 6026</th>
                            <td>BARCELONA</td>
                            <td>15:30</td>
                            <td>15:57</td>
                            <td>LANDED AT 15:58</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">MYT 792</th>
                            <td>RHODES</td>
                            <td>15:35</td>
                            <td>15:13</td>
                            <td>LANDED AT 15:14</td>
                        </tr>
                        <tr>
                            <th scope="row">SN 2055</th>
                            <td>BRUSSELS </td>
                            <td>15:55</td>
                            <td>15:35</td>
                            <td>LANDED AT 15:36</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">EZY 396</th>
                            <td>INVERNESS</td>
                            <td>15:55</td>
                            <td>15:56</td>
                            <td>LANDED AT 15:56</td>
                        </tr>
                        <tr>
                            <th scope="row">BE 1546</th>
                            <td>TOULOUSE</td>
                            <td>15:55</td>
                            <td>15:26</td>
                            <td>LANDED AT 15:26</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">BA 4028</th>
                            <td>MUNICH</td>
                            <td>16:00</td>
                            <td>15:47</td>
                            <td>LANDED AT 15:47</td>
                        </tr>
                        <tr>
                            <th scope="row">BE 1562</th>
                            <td>BORDEAUX</td>
                            <td>16:05</td>
                            <td>16:10</td>
                            <td>LANDED AT 16:10</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">EZY 6162</th>
                            <td>AMSTERDAM</td>
                            <td>16:05</td>
                            <td>16:07</td>
                            <td>LANDED AT 16:07</td>
                        </tr>
                        <tr>
                            <th scope="row">FCA 7301</th>
                            <td>F'VENTURA</td>
                            <td>16:05</td>
                            <td>15:38</td>
                            <td>LANDED AT 15:39</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">KL 1055</th>
                            <td>AMSTERDAM</td>
                            <td>16:20</td>
                            <td>16:14</td>
                            <td>LANDED AT 16:13</td>
                        </tr>
                        <tr>
                            <th scope="row">BA 4027</th>
                            <td>GLASGOW</td>
                            <td>16:40</td>
                            <td>16:28</td>
                            <td>LANDED AT 16:29</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">WOW 486</th>
                            <td>DUBLIN</td>
                            <td>16:50</td>
                            <td>16:48</td>
                            <td>LANDED AT 16:45</td>
                        </tr>
                        <tr>
                            <th scope="row">WOW 305</th>
                            <td>MANCHESTER</td>
                            <td>17:00</td>
                            <td>16:50</td>
                            <td>LANDED AT 16:49</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">EZY 569</th>
                            <td>NEWCASTLE werwerw erwerwerwerwerw werw erwer</td>
                            <td>17:15</td>
                            <td>17:02</td>
                            <td>LANDED AT 17:04</td>
                        </tr>
                        <tr>
                            <th scope="row">BE 1596</th>
                            <td>BERGERAC</td>
                            <td>17:15</td>
                            <td>17:00</td>
                            <td>LANDED AT 17:00</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">EZY 6156</th>
                            <td>GENEVA</td>
                            <td>17:20</td>
                            <td>17:05</td>
                            <td>LANDED AT 17:07</td>
                        </tr>
                        <tr>
                            <th scope="row">BA 4035</th>
                            <td>EDINBURGH</td>
                            <td>17:4065 dytud yude tyu dtyuety utyurt y uryu </td>
                            <td>19:54</td>
                            <td>LANDED AT 19:53</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">XLA 6225</th>
                            <td>RHODES</td>
                            <td>18:10</td>
                            <td>17:53</td>
                            <td>LANDED AT 17:54 drtdf hdhd dfhd fjfg jdfjdfg jdf j</td>
                        </tr>
                        <tr>
                            <th scope="row">EZY 406</th>
                            <td>GLASGOW</td>
                            <td>18:15</td>
                            <td>19:41</td>
                            <td>LANDED AT 19:41</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">FCA 7303</th>
                            <td>LARNACA</td>
                            <td>18:30</td>
                            <td>18:47</td>
                            <td>LANDED AT 18:47</td>
                        </tr>
                        <tr>
                            <th scope="row">T3 4507</th>
                            <td>ABERDEEN</td>
                            <td>18:35</td>
                            <td>18:50</td>
                            <td>LANDED AT 18:50</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">FR 508</th>
                            <td>DUBLIN</td>
                            <td>18:40</td>
                            <td>19:22</td>
                            <td>LANDED AT 19:19</td>
                        </tr>
                        <tr>
                            <th scope="row">BA 7644</th>
                            <td>MILAN</td>
                            <td>18:45</td>
                            <td>18:53</td>
                            <td>LANDED AT 18:53</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">EZY 6174</th>
                            <td>VENICE</td>
                            <td>18:50</td>
                            <td>19:34</td>
                            <td>LANDED AT 19:33</td>
                        </tr>
                        <tr>
                            <th scope="row">EZY 426</th>
                            <td>EDINBURGH</td>
                            <td>19:05</td>
                            <td>19:58</td>
                            <td>LANDED AT 19:59</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">BY 514</th>
                            <td>PAPHOS</td>
                            <td>19:10</td>
                            <td>18:45</td>
                            <td>LANDED AT 18:43</td>
                        </tr>
                        <tr>
                            <th scope="row">EZY 6128</th>
                            <td>PRAGUE</td>
                            <td>19:10</td>
                            <td>19:16</td>
                            <td>LANDED AT 19:15</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">BA 4089</th>
                            <td>PARIS-CDG</td>
                            <td>19:15</td>
                            <td>19:38</td>
                            <td>LANDED AT 19:38</td>
                        </tr>
                        <tr>
                            <th scope="row">BA 4102</th>
                            <td>FRANKFURT</td>
                            <td>19:50</td>
                            <td>19:36</td>
                            <td>LANDED AT 19:36</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">BA 4029</th>
                            <td>GLASGOW</td>
                            <td>19:55</td>
                            <td>19:49</td>
                            <td>LANDED AT 19:48</td>
                        </tr>
                        <tr>
                            <th scope="row">WOW 307</th>
                            <td>MANCHESTER</td>
                            <td>19:55</td>
                            <td>19:56</td>
                            <td>LANDED AT 19:56</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">WOW 487</th>
                            <td>LEEDS/BRAD</td>
                            <td>20:00</td>
                            <td>19:51</td>
                            <td>LANDED AT 19:51</td>
                        </tr>
                        <tr>
                            <th scope="row">KL 1057</th>
                            <td>AMSTERDAM</td>
                            <td>20:30</td>
                            <td>20:21</td>
                            <td>LANDED AT 20:21</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">EZY 573</th>
                            <td>NEWCASTLE</td>
                            <td>20:35</td>
                            <td>20:22</td>
                            <td>LANDED AT 20:24</td>
                        </tr>
                        <tr>
                            <th scope="row">BA 4087</th>
                            <td>PARIS-CDG</td>
                            <td>20:35</td>
                            <td>20:51</td>
                            <td>LANDED AT 20:50</td>
                        </tr>
                        <tr class="dk">
                            <th scope="row">EZY 450</th>
                            <td>BELFAST INTL</td>
                            <td>21:00</td>
                            <td>20:58</td>
                            <td>LANDED AT 20:59</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>


    </body>
</html>
A: 

Change the overflow property to the following:

.innera
        {
            overflow:scroll; /*changed from auto to scroll*/
            height: 100px;
            border: 1px solid #00ff00;
        }
Julian
Really? Wow. I will try that.
Grae
That change did not seem to do anything.
Grae
Thank you, though.
Grae
A: 

Ok, a bit of googling found this, should work for you:

http://blog.oxagile.com/2009/10/26/scrollable-html-table-with-fixed-header-for-ie-7-ie-8-firefox-35-chrome/

the explanation is long, so you better read the source, they have working example there.

Romario