table表格的制作

13 篇文章 0 订阅

简单的表格效果

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>简单的表格效果</title>
        <style>
            table{
                background-color: #fff;
                border: none;
                color: #565;
                font: 12px arial;
                text-align: left;
            }
            table caption{
                font-size: 24px;
                border-bottom: 2px solid #B3DE94;
                border-top: 2px solid #B3DE94;
            }
            table, td, th{
                margin: 0;
                padding: 0;
                vertical-align: middle;
            }
            tbody td, tbody th{
                background: #DFC;
                border-bottom: 2px solid #B3DE94;
                border-top: 3px solid #FFFFFF;
                padding: 9px;
            }
            tfoot td, tfoot th{
                font-weight: bold;
                padding: 4px 8px 6px 9px;
                text-align: center;
            }
            thead th{
                font-size: 14px;
                font-weight: bold;
                line-height: 19px;
                padding: 0 8px 2px;
                text-align: center;
            }
            tbody tr.even th, tbody tr.even td{
                background-color: #CEA;
                border-bottom: 2px solid #67BD2A;
            }
            col.price{
                text-align: right;
            }
        </style>
    </head>
    <body>
        <table summary="book list">
            <caption>Book List</caption>
            <col></col><col></col><col></col><col class="price" align="right"></col><col></col>
            <thead>
                <tr>
                    <th >Title</th>
                    <th >ID</th>
                    <th >Country</th>
                    <th >Price</th>
                    <th >Download</th>
                </tr>
            </thead>	
            <tbody>
                <tr >
                    <th class="even">Tom</th>
                    <td>1213456</td>
                    <td>Germany</td>
                    <td>$3.12</td>
                    <td>Download</td>
                </tr>
                <tr class="odd">
                    <th >Chance</th>
                    <td>1213457</td>
                    <td>Germany</td>
                    <td>$123.34</td>
                    <td>Download</td>
                </tr>
                <tr class="even">
                    <th >John</th>
                    <td>1213458</td>
                    <td>Germany</td>
                    <td>$34.37</td>
                    <td>Download</td>
                </tr>
                <tr class="odd">
                    <th >oKathleen</th>
                    <td>1213459</td>
                    <td>Germany</td>
                    <td>$23.67</td>
                    <td>Download</td>
                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <th >Total</th>
                    <td colspan="4">4 books</td>
                </tr>
            </tfoot>
        </table>
    </body>
</html>

IE6下变换table颜色的TD

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>IE6下变换table颜色的TD</title>
        <style>
            table{
                color: #565;
                font: 12px arial;
            }
            td{
                background-color: #DFC;
                border-bottom: 2px solid #BED394;
                border-top: 3px solid #fff;
                padding: 9px;
            }
            tr:hover, tr.hover{
                background-color: #595;
                color: #fff;
            }

        </style>
    </head>
    <body>
        <table summary="book list">
            <caption>Book List</caption>
            <tr >
                <td >Title</td>
                <td>ID</td>
                <td>Contry</td>
                <td>Price</td>
                <td>Download</td>
            </tr>

            <tr >
                <td >Tom</td>
                <td>1213456</td>
                <td>Germany</td>
                <td>$3.12</td>
                <td>Download</td>
            </tr>
            <tr>
                <td >Chance</td>
                <td>1213457</td>
                <td>Germany</td>
                <td>$123.34</td>
                <td>Download</td>
            </tr>
            <tr >
                <td >John</td>
                <td>1213458</td>
                <td>Germany</td>
                <td>$34.37</td>
                <td>Download</td>
            </tr>
            <tr>
                <td>oKathleen</td>
                <td>1213459</td>
                <td>Germany</td>
                <td>$23.67</td>
                <td>Download</td>
            </tr>
        </table>
        <script language="javascript">
            var rows = document.getElementsByTagName('tr');
            for (var i=0;i<rows.length;i++){
                rows[i].onmouseover = function(){		//鼠标指针在行上面的时候
                    this.className = 'hover';
                }
                rows[i].onmouseout = function(){		//鼠标指针离开时
                    this.className = '';
                }
            }
        </script>
    </body>
</html>

实现表格变换该行和该列的第一个单元格的颜色

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>实现表格变换该行和该列的第一个单元格的颜色</title>
        <style>
            table{
                color: #565;
                font: 12px arial;
            }
            td{
                background-color: #DFC;
                border-bottom: 2px solid #BED394;
                border-top: 3px solid #fff;
                padding: 9px;
            }
            td.hover{
                background-color: #595;
                color: #fff;
            }

        </style>
    </head>
    <body>
        <table summary="book list">
            <caption>Book List</caption>
            <tr >
                <td >Title</td>
                <td>ID</td>
                <td>Contry</td>
                <td>Price</td>
                <td>Download</td>
            </tr>

            <tr >
                <td >Tom</td>
                <td>1213456</td>
                <td>Germany</td>
                <td>$3.12</td>
                <td>Download</td>
            </tr>
            <tr>
                <td >Chance</td>
                <td>1213457</td>
                <td>Germany</td>
                <td>$123.34</td>
                <td>Download</td>
            </tr>
            <tr >
                <td >John</td>
                <td>1213458</td>
                <td>Germany</td>
                <td>$34.37</td>
                <td>Download</td>
            </tr>
            <tr>
                <td>oKathleen</td>
                <td>1213459</td>
                <td>Germany</td>
                <td>$23.67</td>
                <td>Download</td>
            </tr>
        </table>
        <script language="javascript">
            var cells = document.getElementsByTagName('td');
            for (var i=0;i<cells.length;i++){
                cells[i].onmouseover = function(){		//鼠标指针在行上面的时候
                    this.className = 'hover';
                    for(var j = 0;j < cells.length;j++){
                        if(cells[j] == this){
                            //该列的第一个单元格编号
                            cells[j % 5].className = 'hover';
                            //该行的第一个单元格编号
                            cells[j - j % 5].className = 'hover';
                        }
                    }
                }
                cells[i].onmouseout = function(){		//鼠标指针离开时
                    this.className = '';
                    for(var j = 0;j < cells.length;j++){
                        if(cells[j] == this){
                            cells[j % 5].className = '';
                            cells[j - j % 5].className = '';
                        }
                    }
                }
            }
        </script>
    </body>
</html>




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值