html - 是否可以在 HTML 表格中将 rowspan 用作 1.5?

标签 html css html-table frontend

<分区>


想改进这个问题吗? 通过 editing this post 添加细节并澄清问题.

关闭 7 年前

我希望我的第 3 行在外观上看起来像第 1 行。最初我试图给 rowspan="1.5",因为我尝试使用上面的代码它不起作用。当我尝试按照我在实现第 1 行时所遵循的程序进行操作时,会导致错位。

table {
  border-collapse: collapse;
  border: 0px;
}
td {
  padding: 20px;
  border: 1px solid black;
  text-align: center;
}
thead tr th {
  border: 0px;
}
<table border="1" width="100%">
  <thead style="border: 0px solid black;">
    <tr style="border=" 0px ">
      <th style="border: 0px ">Row 1</th>
      <th style="border: 0px ">Row 2</th>
      <th style="border: 0px ">Row 3</th>
    </tr>
  </thead>
    <tr> 
      <td rowspan="2 ">Row 1, cell 1</td>
      <td rowspan="3 ">Row 1, cell 2</td>
      <td >Row 1, cell 3</td>
    </tr>
    <tr>       
      <td>Row 2, cell 3</td>
    </tr>
    <tr>
      <td rowspan="2 ">Row 3, cell 1</td>
      <td rowspan=" ">Row 3, cell 3</td>
    </tr>
    <tr>     
      <td rowspan="3 ">Row 4, cell 2</td>
      <td>Row 4, cell 3</td>
    </tr>
    <tr>
      <td rowspan="2 ">Row 5, cell 1</td>
      <td>Row 5, cell 3</td>
    </tr>
    <tr>
      <td>Row 6, cell 3</td>
    </tr>
</table> 

最佳答案

对于 html 表格,rowspan 不能有 float 值。

根据 W3:

rowspan : This attribute specifies the number of rows spanned by the current cell. The default value of this attribute is one ("1"). The value zero ("0") means that the cell spans all rows from the current row to the last row of the table section (THEAD, TBODY, or TFOOT) in which the cell is defined

编辑: 当您使用 <td rowspan="x">你必须删除 x下一个对应的时间<tr>

这适合你吗?

<table>
  <tr>
    <td rowspan="2">r1 c1</td>
    <td rowspan="3">r1 c2</td>
    <td rowspan="2">r1 c3</td>
  </tr>
  <tr>
  </tr>
  <tr>
    <td rowspan="2">r2 c1</td>
    <td rowspan="2">r2 c3</td>
  </tr>
  <tr>
    <td rowspan="3">r2 c2</td>
  </tr>
  <tr>
    <td rowspan="2">r3 c1</td>
    <td rowspan="2">r3 c3</td>
  </tr>
</table>

关于html - 是否可以在 HTML 表格中将 rowspan 用作 1.5?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37145211/

上一篇:html - 在 div 拉伸(stretch)内设置背景图像

下一篇:jquery - 我正在尝试使用阅读更多按钮创建多个弹出窗口

相关文章:

php - Css 文件没有链接到 html/php 文件

javascript - 图片幻灯片不工作

javascript - 如何对表行和列结构使用模运算符?

javascript - 如何修改我的 JSON 对象?

css - Bootstrap,汉堡包图标在导航栏中没有响应

jQuery 'has attribute' 选择器在 IE7 中失败(对于 'autofocus' )

Javascript 使用 tr id 更改 td 元素的样式

javascript - 通过单击另一个表中的单元格对表进行排序

javascript - setTimeout 连续循环不等待

html - 如何在 div 容器中间垂直居中 h1?