开发者

HTML row table heigth on Firefox

Is there a way Firefox keeps the row height, so if data doesn't fill all the body heigth it keeps an empty space below last row? IE behaves this way, so all rows stay on the top.

I want to code a scroll table with fixed header; sometimes there's not sufficient data on table content to fill the fixed table height.

A sample code:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link rel="stylesheet" href="reset.css"/>
<style type="text/css">
    *    {margin:0}
    table {
        border: solid #66CC99;
        border-width: 0px 1px 1px 0px;
        width: 400px;
    }
    th, td {
        border: solid #66CC99;
        border-width: 1px 0px 0px 1px;
        padding: 4px;
    }
    th {
        background-color: #339999;
        color: #FFFFFF;
    }
    tr.alt td {
        background-color: #EEEEEE;
    }
    tbody {
        height: 200px;
        overflow-y: auto;
        overflow-x: hidden;
    }
</style>
<!--[if IE]>
    <style type="text/css">
        div {
            position: relative;
            height: 200px;
            width: 416px;
            overflow-y: scroll;
            overflow-x: hidden;
            border: solid #66CC99;
            border-width: 0px 0px 1px 0px;
        }
        table {
            border-width: 1px 1px 0px 0px;
        }
        thead tr {
            position: absolute;
            top: expression(this.offsetParent.scrollTop);
        }
        tbody {
            height: auto;
        }
        table tbody tr:first-child td {
            padding: 29px 4px 4px 4px;
        }
    </style>
<![endif]-->










    </head><body>

        <table class="treeTable" id="table" cellpadding="0" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th id="col1" class="text" style="width: 100%;" nowrap="nowrap">NAME</th>
                    <th class="selectable" style="width: 14em;" id="th-122002" nowrap="nowrap">12/2002</th>
                    <th class="selectable" style="width: 14em;" id="th-122007" nowrap="nowrap">12/2007</th>
                    <th class="selectable" style="width: 14em;" id="th-072010" nowrap="开发者_运维技巧nowrap">07/2010</th>
                </tr>
            </thead>
            <tbody id="tbody">
                <tr>
                    <td>
                        Name
                    </td>
                    <td>
                        123
                    </td>
                    <td>
                        123
                    </td>
                    <td>
                        123
                    </td>
                </tr>
                <tr>
                    <td>
                        Name
                    </td>
                    <td>
                        123
                    </td>
                    <td>
                        123
                    </td>
                    <td>
                        123
                    </td>
                </tr>
            </tbody>
        </table>

</body></html>


One solution that works to a certain extent but doesn't seem perfect is to add this as the last row:

<tr style="height: 100%;"></tr>

It seems to create an empty row that is the size of the area meaning that you can scroll off the bottom til there is only white space which probably isn't ideal. You might be able to play with this a bit (possibly do some rough calculations to work out a sensible height based on how many rows you have) to get a working solution.


Did you specify the height attribute, set it to desired value and then see.


Can you possibly paste your code? I'd also recommend using a reset.css to remove any prejudice different browsers have interpreting your code.


You can set '&nbsp' as a data if there is no value or you can do is set style attribute to your 'td' tag as <td style="height: 15px;"> </td>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜