html - 如何使表格标题的高度彼此不同?

标签 html css css-tables

我正在尝试制作一个具有不同大小标题的表格,如下图所示:

enter image description here

我可以使用 css 更改宽度,但不能更改高度。

th:nth-child(3) {
    background-color:green !important;
    height:20%;
    width:5%;
    padding:5%;
}
th:nth-child(1),th:nth-child(2) {
    background-color:purple !important;
    height:50% !important;
    width:1%;
    padding:1%;
}

https://jsfiddle.net/pq01hc7y/2/

最佳答案

这个 fiddle 在文档中重新创建表格:

https://jsfiddle.net/fucrza92/

最重要的部分是:

<tr>
  <th rowspan="2">MATERIAL</th>
  <th rowspan="2">ALLOY</th>
  <th colspan="5">TUBE OD (INCH)</th>
</tr>
<tr>
  <th>0.250</th>
  <th>0.375</th>
  <th>0.500</th>
  <th>0.625</th>
  <th>0.750</th>
</tr>

使用 rowspan 和两个标题行可以使某些标题元素比其他元素高。对于 TUBE OD 元素,同样的原则适用于具有 colspan 的列。

关于html - 如何使表格标题的高度彼此不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41385285/

相关文章:

javascript - 如何将单击的元素从侧边栏显示到第一个位置并隐藏剩余列表并在悬停时显示列表

html - 即使在指定文档类型后中心对齐也不起作用

html - 在 div 中,如何设置 "cell spacing"?

html - 在 html/css 中水平和垂直居中对齐文本

javascript - 新选项卡中的 Base64 PDF 在刷新前显示空白页

css - IE9 与 Opera、Firefox 与 Opera 的 CSS 定位差异

html - Navbar div 按边界偏离中心

javascript - 同时将鼠标悬停在多个 Div 上,使其看起来像 1 个 div

css - 布局、CSS 表格、表格单元格和旁边列上的丑陋间隙

html - 如何删除 div 表格单元格中的垂直填充?