第三天--html表格

來源:互聯網
上載者:User

標籤:

<!Doctype html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="keywords" content="">
        <meta name="description" content="">
        <meta name="author" content="">
        <meta http-equive="refresh" content="30">
        <title>第三天(html表格)</title>
    </head>
    <body>
        <table border="1"><!--border="1"意思是每個格子包括外面的大盒子都有像素為1的邊框-->
            <tr>
                <th>這是頭部第一行,第一格</th>
                <th>這是頭部第一行,第二格</th>
                <!--<th>標籤代表表格頭部-->
            </tr>
            <tr>
                <td>這是第一行,第一格</td>
                <td>這是第一行,第二格</td>
            </tr>
            <tr>
                <td>這是第二行,第一格</td>
                <td>這是第二行,第二格</td>
            </tr>
        </table>




        <table><!--如果不定義邊框則沒有邊框,但大多數都是要定義邊框的-->
            <tr>
                <th>這是頭部第一行,第一格</th>
                <th>這是頭部第一行,第二格</th>
                <!--<th>標籤代表表格頭部-->
            </tr>
            <tr>
                <td>這是第一行,第一格</td>
                <td>這是第一行,第二格</td>
            </tr>
            <tr>
                <td>這是第二行,第一格</td>
                <td>這是第二行,第二格</td>
            </tr>
        </table>


        <!--帶有標題的表格-->
        <table>
            <caption style="text-align:left;font-weight:bold">我是表格標題</caption><!--<caption>標籤寫在table中用來定義表格標題-->
            <tr>
                <td>這是第一行,第一格</td>
                <td>這是第一行,第二格</td>
            </tr>
            <tr>
                <td>這是第二行,第一格</td>
                <td>這是第二行,第二格</td>
            </tr>
        </table>

<!--儲存格跨兩格(即儲存格誇兩行)-->
        <table border=“1” >
            <tr  align="center"><!--其中align="center"放在tr中是為了讓儲存格內的字置中,若是放在table標籤中則是整個表格置中-->
                <td>這是第一行,第一格</td>
                <td colspan="2">我自己佔據兩個格子</td>
                

            </tr>
            <tr>
                <td>這是第二行,第一格</td>
                <td>這是第二行,第二格</td>
                <td>這是第二行,第三格</td>
            </tr>
        </table>
        <!--colspan="2"中的“2”就是佔據幾個儲存格的數值,上一個行的表格佔有幾個儲存格,下面幾行就要有幾個儲存格來撐,不然不顯示佔據兩個儲存格的效果-->




            <!--儲存格跨兩列-->
        <table border=“1” style="margin-top:30px">
            
            <tr>
                <td rowspan="3">我自己佔三列</td>
                <td>這是第二行,第三格</td>
            </tr>
            <tr>
                <td>這是第二行,第三格</td>
            </tr>

        </table>



        <!--儲存格跨三列-->
        <table border=“1” style="margin-top:30px">
            
            <tr>
                <td rowspan="3">我自己佔三列</td>
                <td>這是第二行,第三格</td>
        
            </tr>
            <tr>
                <td>這是第二行,第三格</td>
            </tr>

            <tr>
                <td>這是第二行,第三格</td>
            </tr>
        
        </table>
        <!--rowspan="2"中的“2”就是佔據幾列的數值,詳解與佔據兩個儲存格類似,特別注意:佔據列的時候在本列中要單專屬個與之同一列中,為了是往後佔位達到效果-->




    <!--表格內添加東西-->
        <table border=“1” style="margin-top:30px">
            
            <tr>
                <td>
                <p>這是段落一</p>
                <p>這是段落二</p>
                </td>
                <td>這個儲存格內包含一個表格:
                    <table border="1">
                        <tr>
                            <td>一</td>
                            <td>二</td>
                        </tr>
                        <tr>
                            <td>三</td>
                            <td>四</td>
                        </tr>
                    </table>
                </td>
        
            </tr>
            <tr>
                <td>
                    這個儲存格包含一個列表:
                    <ul>
                        <li>我是大娃</li>
                        <li>我是二娃</li>
                        <li>我是三娃</li>
                        <li>其他娃還沒出來</li>
                    </ul>
                </td>

                <td>
                    這裡可以加個圖片:
                    <img src="img.jpg" alt="這是圖片" title="圖片" style="display:block">
                    <!--其中的display:block樣式是將圖片行內元素強制轉化為區塊層級元素-->
                </td>
            </tr>




        
        
        </table>

        <!--帶有thead、tbody、tfoot的表格,不加這三樣表格也沒有問題,加這三樣是為了方便統一改變不同部分的樣式-->

            <!--加邊框是不是好醜?!不加邊框就不像表格了,怎麼破怎麼破!!下面就看看各種小東西吧-->

            <table border=“1” style="margin-top:30px" rules="all" bordercolor="red">
            <!-- rules="rows"去掉豎線,rules="cols"去掉橫線,rules="all"去掉雙邊匡,留下橫豎線,rules="grounps"是每個儲存格都顯示邊框,
            
                bordercolor="red"控制所有邊框為紅色
                border-collapse屬性是合并邊框,切只能寫在style裡面,他不是表格內建的屬性,是樣式屬性
                -->

                <thead>
                    <tr>
                        <th>頁首一</th>
                        <th>頁首二</th>
                    </tr>
            
                </thead>
                
                <tbody style="border:1px solid blue"><!--這裡定義表格體部分的外邊框顏色,把上面的border邊框顏色覆蓋掉了.注意:這個單獨定義邊框的必須寫在樣式中-->
                    <tr>
                        <td>這是內容</td>
                        <td>這是內容</td>
                
                    </tr>
                    <tr>
                        <td>這是內容</td>
                        <td>這是內容</td>
                    </tr>
                </tbody>

                <tfoot bgcolor="pink"><!--bgcolor是表格內建的屬性,用來設定表格背景顏色-->
                    <tr>
                        <td>這是底部</td>
                        <td>這是底部</td>
                    </tr>
                </tfoot>
            </table>
        
    </body>
</html>

第三天--html表格

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.