zoukankan      html  css  js  c++  java
  • table合并单元格 colspan(跨列)和rowspan(跨行)

    table合并单元格 colspan(跨列)和rowspan(跨行)

    `

    colspanrowspan这两个属性用于创建特殊的表格。

    colspan是“column span(跨列)”的缩写。colspan属性用在td标签中,用来指定单元格横向跨越的列数


    在浏览器中将显示如下:

    单元格1
    单元格2 单元格3 单元格4

    该例通过把colspan设为“3”, 令所在单元格横跨了三列。如果我们将colspan设为“2”,则该单元格将只跨越两列,于是有必要在第一行插入另外一个单元格,以确保两行占据相同的列数。


    该例在浏览器中将显示如下:

    单元格1 单元格2
    单元格3 单元格4 单元格5

    rowspan的作用是指定单元格纵向跨越的行数


    浏览器中将显示如下:

    单元格1 单元格2
    单元格3
    单元格4

    上例中的单元格1,其rowspan被设为“3”,这表示该单元格必须跨越三行(本身一行,加上另外两行)。因此,单元格1和单元格2在同一行,而单元格3和单元格4形成独立的两行。

    综合实例

    ss
           
           
         
       
         

    <html>
    <head>

    </head>

    <table border= "1 "   width= "200 " >
         <tr>
            <td colspan="4"  >ss

            </td>
         </tr>
         <tr>
            <td   width= "25% ">   </td>  
            <td   width= "25% ">   </td>  
            <td   width= "25% ">   </td>  
            <td   width= "25% ">   </td> 
         </tr>
         <tr>
            <td   width= "25% "rowspan="2">   </td>  
            <td   width= "25% ">   </td>  
            <td   width= "25% ">   </td>  
            <td   width= "25% ">   </td> 
         </tr>
         <tr>

            <td   width= "25% ">   </td>  
            <td   width= "25% " rowspan="3">   </td>  
            <td   width= "25% ">   </td> 
         </tr>
         <tr>
            <td   width= "25% " colspan="2"  >   </td>  
            <td   width= "25% ">   </td>  


         </tr>
         <tr>
            <td   width= "25% ">   </td>  
            <td   width= "25% ">   </td>  
            <td   width= "25% ">   </td>  

         </tr>
    </table>

    </html>

    `

  • 相关阅读:
    LeetCode 227. Basic Calculator II
    LeetCode 224. Basic Calculator
    LeetCode 103. Binary Tree Zigzag Level Order Traversal
    LeetCode 102. Binary Tree Level Order Traversal
    LeetCode 106. Construct Binary Tree from Inorder and Postorder Traversal
    LeetCode 105. Construct Binary Tree from Preorder and Inorder Traversal
    LeetCode 169. Majority Element
    LeetCode 145. Binary Tree Postorder Traversal
    LeetCode 94. Binary Tree Inorder Traversal
    LeetCode 144. Binary Tree Preorder Traversal
  • 原文地址:https://www.cnblogs.com/05-hust/p/14132139.html
Copyright © 2011-2022 走看看