HTML表格单元格合并

时间:2017-10-10 08:23:05

标签: html html-table rows

如何在html中执行下表?

Meteor.startup(() => {
 Accounts.onCreateUser(function(options, user) {
if (options.token)
    user.token = options.token;
if (options.profile)
    user.profile = options.profile;
return user;
 });
})

最后一个是合并两行和两列。

在不使用CSS的情况下感谢您的帮助。

表有5行3列。

5 个答案:

答案 0 :(得分:1)



    <table>
        <tr>
            <td>1</td>
            <td>2</td>
            <td>3</td>
        </tr>
        <tr>
            <td>1</td>
            <td colspan="2">2 & 3</td>
        </tr>
        <tr>
            <td>1</td>
            <td>2</td>
            <td>3</td>
        </tr>
        <tr>
            <td colspan="2">1 & 2</td>
            <td>3</td>
        </tr>
        <tr>
            <td colspan="2">1 & 2</td>
            <td>3</td>
        </tr>
    </table>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

你可以使用colspan和rowspan来做这件事。 Colspan允许单个表格单元格跨越多个单元格或列的宽度。

Rowspan允许单个表格单元格跨越多个单元格或行的高度。

了解详情:https://html.com/tables/rowspan-colspan/#ixzz4v5ntM7rn

&#13;
&#13;
table, th, td {
    border: 1px solid black;
}
&#13;
<table>
    <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
    </tr>
    <tr>
        <td>1</td>
        <td colspan="2">2 & 3</td>
    </tr>
    <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
    </tr>
    <tr>
        <td rowspan="2" colspan="2">1 & 2</td>
         <td >3</td>
    </tr>
    <tr>
        
        <td>3</td>
    </tr>
</table>
&#13;
&#13;
&#13;

答案 2 :(得分:1)

&#13;
&#13;
table, th, td {
    border: 1px solid black;
}
&#13;
<table>
  <tr>
    <td>January</td>
    <td>$100</td>
    <td>$50</td>
  </tr>
  <tr>
    <td>January</td>
    <td colspan="2">$50</td>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
    <td>$50</td>
  </tr>
  <tr>
    <td rowspan="2" colspan="2">January</td>
    <td>$50</td>
  </tr>
  <tr>
    <td>$50</td>
  </tr>
</table>
&#13;
&#13;
&#13;

答案 3 :(得分:0)

colspan代码上使用<td>

<table>
  <tr>
    <td>Col 1</td>
    <td>Col 2</td>
    <td>Col 3</td> 
  </tr>
  <tr>
    <td>Col 1</td>
    <td colspan="2">Col 2 + Col 3</td>
  </tr>
  <tr>
    <td>Col 1</td>
    <td>Col 2</td>
    <td>Col 3</td>
  </tr>
<table>

https://codepen.io/Toilal/pen/BwxdMg

答案 4 :(得分:0)

&#13;
&#13;
tr:nth-child(1), tr:nth-child(3), tr:nth-child(5){
  font-weight: bold;
  font-size: 15pt;
}
tr:nth-child(2){
  font-weight: bold;
  font-size: 14pt;
}
td:nth-child(1){
  border-left: 2px solid black;
  border-right: 2px solid black;
}
td:nth-child(2){
  border-right: 2px solid black;
}
td:nth-child(3){
  border-right: 2px solid black;
}
tr:nth-child(4) > td:nth-child(1), tr:nth-child(4) > td:nth-child(2){
  border-left: none;
  border-right: 1px solid black;
}
&#13;
<table>
  <tr>
    <td>Cell1</td>
    <td>Cell2</td>
    <td>Cell3</td>
  </tr>
  <tr>
    <td>Cell1</td>
    <td colspan="2">Cell2 & 3</td>
  </tr>
  <tr>
    <td>Cell1</td>
    <td>Cell2</td>
    <td>Cell3</td>
  </tr>
  <tr>
    <td colspan="2">Cell1 & 2</td>
    <td>Cell3</td>
  </tr>
  <tr>
    <td colspan="2">Cell1 & 2</td>
    <td>Cell3</td>
  </tr>

</table>
&#13;
&#13;
&#13;