使整个行中的`td'跨度

时间:2017-10-23 17:23:25

标签: html css reactjs

我在td整个tr内遇到麻烦,但是我无法让它正常工作。这是截图: screenshot

行已经存在问题,但这次td提出了问题。

<div className="jumbotron col-sm-12 text-left row">
                    <div className="panel panel-info">
                        <div className="panel-heading">
                            HEADER
                        </div>
                    </div>

                    <table
                        id="templateTable"
                        className="table table-bordered table-condensed table-responsive">
                        <tbody className="row">
                            <tr className="col-sm-6">
                                <td className="col-sm-12">
                                    {"Hello1"}
                                </td>
                            </tr>
                            <tr className="col-sm-6">
                                <td className="col-sm-12">
                                    {"Hello2"}
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>

1 个答案:

答案 0 :(得分:1)

设置要在整个表格中跨越的colspan元素的td属性:

&#13;
&#13;
table,
th,
td {
  border: 1px solid black;
}
&#13;
<table>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
  <tr>
    <td colspan="2">Sum: $180</td>
    <!-- notice this td spans multiple columns -->
  </tr>
</table>
&#13;
&#13;
&#13;

基本上,您只需将colspan设置为等于表格中的列数即可获取表格的整个宽度。

https://www.w3schools.com/tags/att_td_colspan.asp