【问题标题】:How to merge table cells of same values in bootstrap table?如何在引导表中合并相同值的表格单元格?
【发布时间】:2021-12-16 20:59:15
【问题描述】:

我需要将年份中相同的单元格合并为一个单元格,在该单元格下根据相应的年份排列月份。我尝试获取年份计数并将其用作 colspan 值,但它不起作用

<thead>
  <tr>
    <th *ngFor="let colItem of YearGrid">{{colItem.Year}}</th>
  </tr>
  <tr>
    <th *ngFor="let colItem of YearGrid">{{colItem.Month}}</th>
  </tr>
</thead>
YearGrid = [
  {Month: 'Nov', Year: 2020},
  {Month: 'Dec', Year: 2020},
  {Month: 'Jan', Year: 2021},
  {Month: 'Feb', Year: 2021},
  {Month: 'Mar', Year: 2021}
];

【问题讨论】:

    标签: javascript html css angular


    【解决方案1】:

    所以请使用 colspan 或 rowspan

    table{
    width: 400px
    }
    
    table td,table th{
    border: 1px solid red;
    }
    <table>
      <tr>
        <th colspan="2">Name</th>
        <th>Age</th>
      </tr>
      <tr>
        <td>Jill</td>
        <td>Smith</td>
        <td>43</td>
      </tr>
      <tr>
        <td>Eve</td>
        <td>Jackson</td>
        <td>57</td>
      </tr>
    </table>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-28
      • 1970-01-01
      • 2020-08-21
      • 2021-09-20
      相关资源
      最近更新 更多