html中表格table冻结行和列

本文介绍了两种在HTML表格中实现冻结行和列的方法,包括详细步骤和参考资料来源,帮助读者理解和应用表格冻结技术。
摘要由CSDN通过智能技术生成

 

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>完美冻结列和行 </title>
    <style type="text/css">
        .FixedHeaderColumnsTableDiv
        {
            overflow: auto;
            position: relative;
        }
        .FixedCell
        {
            position: relative;
            top: expression(this.offsetParent.scrollTop);
            left: expression(this.parentElement.offsetParent.scrollLeft);
            z-index: 1800;
        }
        .FixedHeaderRow1
        {
            position: relative;
            top: expression(this.offsetParent.scrollTop);
            background-color: #ccc;
            z-index: 300;
        }
        .FixedHeaderRow2
        {
            position: relative;
            top: expression(this.offsetParent.scrollTop);
            z-index: 290;
            background-color:#ffccff;
        }
        .FixedDataColumn
        {
            position: relative;
            left: expression(this.parentElement.offsetParent.parentElement.scrollLeft);
            z-index: 200;
            background-color: Aqua;
        }
    </style>
</head>
<body>
    <div class="FixedHeaderColumnsTableDiv" style="width: 1000px; height: 100px">
        <table border="0" cellpadding="0" cellspacing="0" width="1200px">
            <tr class="FixedHeaderRow1">
                <td class="FixedCell" style="width: 80px">
                    header1
                </td>
                <td class="FixedCell" style="width: 80px">
                    header2
                </td>
                <td class="FixedCell" style="width: 80px">
                    header3
                </td>
                <td class="FixedCell" style="width: 80px">
                    header4
                </td>
                <td style="width: 80px">
                    header5
                </td>
                <td style="width: 80px">
                    header6
                </td>
                <td style="width: 80px">
                    header7
                </td>
                <td style="width: 80px">
                    header8
                </td>
                <td style="width: 80px">
                    header9
                </td>
                <td style="width: 80px">
                    header10
                </td>
            </tr>
            <tr class="FixedHeaderRow2">
                <td class="FixedCell" style="width: 80px" align="center">
                    ss
                </td>
                <td class="FixedCell" style="width: 80px" align="center">
                    ss
                </td>
                <td class="FixedCell" style="width: 80px">
                    header16
                </td>
                <td class="FixedHeaderColumn1" colspan="7" align="center">
                    header17dddddddddddd
                </td>
            </tr>
            <tr>
                <td class="FixedDataColumn">
                    col1
                </td>
                <td class="FixedDataColumn">
                    col2
                </td>
                <td class="FixedDataColumn">
                    col3
                </td>
                <td class="FixedDataColumn">
                    col4
                </td>
                <td>
                    col5
                </td>
                <td>
                    col6
                </td>
                <td>
                    col7
                </td>
                <td>
                    col8
                </td>
                <td>
                    col9
                </td>
                <td>
                    col10
                </td>
            </tr>
            <tr>
                <td class="FixedDataColumn">
                    col1
                </td>
                <td class="FixedDataColumn">
                    col2
                </td>
                <td class=&
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值