zoukankan      html  css  js  c++  java
  • HTML与CSS(图解4):表格

    表格的颜色:

    <html>
    <head>
    <title>年度收入</title>
    <style>
    <!--
    body{
        background-color:#ebf5ff;    /* 页面背景色 */
        margin:0px; padding:4px;
        text-align:center;            /* 居中对齐(IE有效) */
    }
    .datalist{
        color:#0046a6;                /* 表格文字颜色 */
        background-color:#d2e8ff;    /* 表格背景色 */
        font-family:Arial;            /* 表格字体 */
    }
    .datalist caption{
        font-size:18px;                /* 标题文字大小 */
        font-weight:bold;            /* 标题文字粗体 */
    }
    .datalist th{
        color:#003e7e;                /* 行、列名称颜色 */
        background-color:#7bb3ff;    /* 行、列名称的背景色 */
    }
    -->
    </style>
       </head>
    <body> 
    <table summary="This table shows the yearly income for years 2004 through 2007" border="1" class="datalist">
        <caption>年度收入 2004 - 2007</caption>
        <tr>
            <th></th>
            <th scope="col">2004</th>
            <th scope="col">2005</th>
            <th scope="col">2006</th>
            <th scope="col">2007</th>
        </tr>
        <tr>
            <th scope="row">拨款</th>
            <td>11,980</td>
            <td>12,650</td>
            <td>9,700</td>
            <td>10,600</td>
        </tr>
        <tr>
            <th scope="row">捐款</th>
            <td>4,780</td>
            <td>4,989</td>
            <td>6,700</td>
            <td>6,590</td>
        </tr>
        <tr>
            <th scope="row">投资</th>
            <td>8,000</td>
            <td>8,100</td>
            <td>8,760</td>
            <td>8,490</td>
        </tr>
        <tr>
            <th scope="row">募捐</th>
            <td>3,200</td>
            <td>3,120</td>
            <td>3,700</td>
            <td>4,210</td>
        </tr>
        <tr>
            <th scope="row">销售</th>
            <td>28,400</td>
            <td>27,100</td>
            <td>27,950</td>
            <td>29,050</td>
        </tr>
        <tr>
            <th scope="row">杂费</th>
            <td>2,100</td>
            <td>1,900</td>
            <td>1,300</td>
            <td>1,760</td>
        </tr>
        <tr>
            <th scope="row">总计</th>
            <td>58,460</td>
            <td>57,859</td>
            <td>58,110</td>
            <td>60,700</td>
        </tr>
    </table>
    </body>
    </html>

    注意:

    Scope属性定义了行的表头和列的表头:
    col: 列表头 
    row: 行表头
    在第一行的加上值为col的scope属性,声明他们是下面(列)数据单元格的表头。同样的,给每行的开头加上值为row的scope属性声明他们是右边(行)数据单元格的表头。
    
    Scope属性还有两个值:
    colgroup: 定义列组(column group)的表头信息 
    rowgroup: 定义行组(row group)的表头信息

    表格边框:

    <html>
    <head>
    <title>年度收入</title>
    <style>
    <!--
    .datalist{
        border:1px solid #429fff;    /* 表格边框 */
        font-family:Arial;
        border-collapse:collapse;    /* 边框重叠 */
    }
    .datalist caption{
        padding-top:3px;
        padding-bottom:2px;
        font:bold 1.1em;
        background-color:#f0f7ff;
        border:1px solid #429fff;    /* 表格标题边框 */
    }
    .datalist th{
        border:1px solid #429fff;    /* 行、列名称边框 */
        background-color:#d2e8ff;
        font-weight:bold;
        padding-top:4px; padding-bottom:4px;
        padding-left:10px; padding-right:10px;
        text-align:center;
    }
    .datalist td{
        border:1px solid #429fff;    /* 单元格边框 */
        text-align:right;
        padding:4px;
    }
    -->
    </style>
       </head>
    <body> 
    <table class="datalist">
        <caption>年度收入 2004 - 2007</caption>
        <tr>
            <th></th>
            <th scope="col">2004</th>
            <th scope="col">2005</th>
            <th scope="col">2006</th>
            <th scope="col">2007</th>
        </tr>
        <tr>
            <th scope="row">拨款</th>
            <td>11,980</td>
            <td>12,650</td>
            <td>9,700</td>
            <td>10,600</td>
        </tr>
        <tr>
            <th scope="row">捐款</th>
            <td>4,780</td>
            <td>4,989</td>
            <td>6,700</td>
            <td>6,590</td>
        </tr>
        <tr>
            <th scope="row">投资</th>
            <td>8,000</td>
            <td>8,100</td>
            <td>8,760</td>
            <td>8,490</td>
        </tr>
        <tr>
            <th scope="row">募捐</th>
            <td>3,200</td>
            <td>3,120</td>
            <td>3,700</td>
            <td>4,210</td>
        </tr>
        <tr>
            <th scope="row">销售</th>
            <td>28,400</td>
            <td>27,100</td>
            <td>27,950</td>
            <td>29,050</td>
        </tr>
        <tr>
            <th scope="row">杂费</th>
            <td>2,100</td>
            <td>1,900</td>
            <td>1,300</td>
            <td>1,760</td>
        </tr>
        <tr>
            <th scope="row">总计</th>
            <td>58,460</td>
            <td>57,859</td>
            <td>58,110</td>
            <td>60,700</td>
        </tr>
    </table>
    </body>
    </html>

    隔行变色:

    <html>
    <head>
    <title>Member List</title>
    <style>
    <!--
    .datalist{
        border:1px solid #0058a3;    /* 表格边框 */
        font-family:Arial;
        border-collapse:collapse;    /* 边框重叠 */
        background-color:#eaf5ff;    /* 表格背景色 */
        font-size:14px;
    }
    .datalist caption{
        padding-bottom:5px;
        font:bold 1.4em;
        text-align:left;
    }
    .datalist th{
        border:1px solid #0058a3;    /* 行名称边框 */
        background-color:#4bacff;    /* 行名称背景色 */
        color:#FFFFFF;                /* 行名称颜色 */
        font-weight:bold;
        padding-top:4px; padding-bottom:4px;
        padding-left:12px; padding-right:12px;
        text-align:center;
    }
    .datalist td{
        border:1px solid #0058a3;    /* 单元格边框 */
        text-align:left;
        padding-top:4px; padding-bottom:4px;
        padding-left:10px; padding-right:10px;
    }
    .datalist tr.altrow{
        background-color:#c7e5ff;    /* 隔行变色 */
    }
    -->
    </style>
       </head>
    <body> 
    <table class="datalist" summary="list of members in EE Studay">
        <caption>Member List</caption>
        <tr>
            <th scope="col">Name</th>
            <th scope="col">Class</th>
            <th scope="col">Birthday</th>
            <th scope="col">Constellation</th>
            <th scope="col">Mobile</th>
        </tr>
        <tr>                    <!-- 奇数行 -->
            <td>isaac</td>
            <td>W13</td>
            <td>Jun 24th</td>
            <td>Cancer</td>
            <td>1118159</td>
        </tr>
        <tr class="altrow">        <!-- 偶数行 -->
            <td>girlwing</td>
            <td>W210</td>
            <td>Sep 16th</td>
            <td>Virgo</td>
            <td>1307994</td>
        </tr>
        <tr>                    <!-- 奇数行 -->
            <td>tastestory</td>
            <td>W15</td>
            <td>Nov 29th</td>
            <td>Sagittarius</td>
            <td>1095245</td>
        </tr>
        <tr class="altrow">        <!-- 偶数行 -->
            <td>lovehate</td>
            <td>W47</td>
            <td>Sep 5th</td>
            <td>Virgo</td>
            <td>6098017</td>
        </tr>
        <tr>                    <!-- 奇数行 -->
            <td>slepox</td>
            <td>W19</td>
            <td>Nov 18th</td>
            <td>Scorpio</td>
            <td>0658635</td>
        </tr>
        <tr class="altrow">        <!-- 偶数行 -->
            <td>smartlau</td>
            <td>W19</td>
            <td>Dec 30th</td>
            <td>Capricorn</td>
            <td>0006621</td>
        </tr>
        <tr>                    <!-- 奇数行 -->
            <td>whaler</td>
            <td>W19</td>
            <td>Jan 18th</td>
            <td>Capricorn</td>
            <td>1851918</td>
        </tr>
        <tr class="altrow">        <!-- 偶数行 -->
            <td>shenhuanyan</td>
            <td>W25</td>
            <td>Jan 31th</td>
            <td>Aquarius</td>
            <td>0621827</td>
        </tr>
        <tr>                    <!-- 奇数行 -->
            <td>tuonene</td>
            <td>W210</td>
            <td>Nov 26th</td>
            <td>Sagittarius</td>
            <td>0091704</td>
        </tr>
        <tr class="altrow">        <!-- 偶数行 -->
            <td>ArthurRivers</td>
            <td>W91</td>
            <td>Feb 26th</td>
            <td>Pisces</td>
            <td>0468357</td>
        </tr>
        <tr>                    <!-- 奇数行 -->
            <td>reconzansp</td>
            <td>W09</td>
            <td>Oct 13th</td>
            <td>Libra</td>
            <td>3643041</td>
        </tr>
        <tr class="altrow">        <!-- 偶数行 -->
            <td>linear</td>
            <td>W86</td>
            <td>Aug 18th</td>
            <td>Leo</td>
            <td>6398341</td>
        </tr>
        <tr>                    <!-- 奇数行 -->
            <td>laopiao</td>
            <td>W41</td>
            <td>May 17th</td>
            <td>Taurus</td>
            <td>1254004</td>
        </tr>
        <tr class="altrow">        <!-- 偶数行 -->
            <td>dovecho</td>
            <td>W19</td>
            <td>Dec 9th</td>
            <td>Sagittarius</td>
            <td>1892013</td>
        </tr>
        <tr>                    <!-- 奇数行 -->
            <td>shanghen</td>
            <td>W42</td>
            <td>May 24th</td>
            <td>Gemini</td>
            <td>1544254</td>
        </tr>
        <tr class="altrow">        <!-- 偶数行 -->
            <td>venessawj</td>
            <td>W45</td>
            <td>Apr 1st</td>
            <td>Aries</td>
            <td>1523753</td>
        </tr>
        <tr>                    <!-- 奇数行 -->
            <td>lightyear</td>
            <td>W311</td>
            <td>Mar 23th</td>
            <td>Aries</td>
            <td>1002908</td>
        </tr>
    </table>
    </body>
    </html>

     

     

     

  • 相关阅读:
    数据库查询服务框架
    postgresql清理工具
    postgre索引
    SAP模块一句话入门(专业术语的理解)
    SAP订单结算详解
    SAP Datasheet
    ASP.NET MVC5 网站开发实践
    VMware S/4 HANA OP 1511虚拟机下载,64G内存限制解决方案
    SAP标准教材列表
    SAP文章链接
  • 原文地址:https://www.cnblogs.com/KeenLeung/p/2494958.html
Copyright © 2011-2022 走看看