html - 如何使用 rowspan 和 colspan 在 html 中制作表格?

标签 html bootstrap-4

如何在 html 中构建此表??

enter image description here

我想使用 rowspan 和 colspan 制作表格?

  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"/>


<table class="table table-bordered">
  <thead>
    <th>Subject</th>
    <th>Result</th>
  </thead>
  <tbody>
    <tr>
      <td>Science</td>
      <td>Physics</td>
      <td>Chemistry</td>
      <td>Other Science</td>
      <td>Math</td>
      <td>English</td>
    </tr>
  </tbody>
</table>

最佳答案

可以了解<table>标签在 MDN 你可以这样做:

table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" />

<table class="table table-bordered">
  <thead>
    <tr>
      <th colspan="2">Subject</th>
      <th>Result</th>
    </tr>

  </thead>
  <tbody>
    <tr>
      <td rowspan="2">Science</td>
      <td>Physics</td>
      <td>A</td>

    </tr>
    <tr>
      <td>Chemistry</td>
      <td>A</td>
    </tr>
    <tr>
      <td rowspan="2">Other Science</td>
      <td>Biology</td>
      <td>B</td>
    </tr>
    <tr>
      <td>Geography</td>
      <td>A</td>
    </tr>
    <tr>
      <td colspan="2">Math</td>
      <td>A+</td>
    </tr>
    <tr>
      <td colspan="2">English</td>
      <td>A+</td>

    </tr>

  </tbody>
</table>

关于html - 如何使用 rowspan 和 colspan 在 html 中制作表格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65274294/

相关文章:

java - html表单提交用java处理响应页面

html - Bootstrap 网格,中间内容粘在页面顶部

html - 无法将内容放入 Bootstrap 4 的容器中

javascript - 如何在 javascript 中调用图像

html - 如何在 Bootstrap 4 中添加下拉菜单?

html - 如何在水平子导航中居中元素

html - 用于滑入和滑出屏幕的 div 按钮(取决于用户的鼠标)

javascript - chrome dev tool中如何通过jquery获取element set的事件监听器?

javascript - 如何替换js中的html标签?

javascript - jquery 而 php 显示隐藏