如何在Bootstrap表中拆分已经拆分的单元格

时间:2020-06-13 11:09:00

标签: html bootstrap-4 html-table

我有一个包含多行的引导表。我想将单元格拆分为不同的部分,我能够拆分Split-1行,但是我很困惑如何将Split-1拆分为Split-2。我正在尝试使用rowspan实现Split-2,但是由于某种原因,它变得一团糟。有人可以帮帮我吗。 enter image description here

 <table class="table table-bordered">
    <tbody>
        <tr>
            <td rowspan="2" style="background-color: #a854a8;text-align: center;"> MAIN FIELD </td>
            <td > TIME-1 </td>
            <td>
                <input type="datetime-local" class="form-control" ng-model="formdata.time" id="time" placeholder="Time 2">
            </td>
        </tr>
        <tr>
            <td style="background-color: #eedded;width: 10%;"> TIME-2 </td>
            <td>
                <input type="datetime-local" class="form-control" ng-model="formdata.time2" id="time2" placeholder="Time2">
            </td>
        </tr>
    </tbody>
</table>

1 个答案:

答案 0 :(得分:1)

您很近...下面的代码段应该有所帮助:

th {
  background-color: lightpink;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">

<table class="table table-bordered">
  <tr>
    <th>column 1</th>
    <th>column 2</th>
    <th>column 3</th>
  </tr>
  <tr>
    <td rowspan="4" style="background-color: #a854a8;text-align: center;">Main field</td>
    <td rowspan="2" style="background-color: #eedded;width: 10%;">Time1 split 1</td>
    <td>split-2 result</td>
  </tr>
  <tr>
    <td>split-2 result</td>
  </tr>
  <tr>
    <td rowspan="2" style="background-color: #eedded;width: 10%;">Time2 split 1</td>
    <td>split-2 result</td>
  </tr>
  <tr>
    <td>split-2 result</td>
  </tr>
</table>

相关问题