html - 在 div 中包含 td

标签 html

我有一个表格,我想在其中包含一个 div,以便该 div 包含一些表格行。但是它不起作用。

<table>
<tr><td> one</td></tr>

<div style="color: yellow;">
<tr><td> two</td></tr>
<tr><td> three</td></tr>
</div>

<tr><td> four </td></tr>
</table>

是否可以将表格行包含在一个 div 中?

非常感谢您提供的任何建议。

最佳答案

使用 <tbody>将行分组在一起的标记:

<table>
    <tr><td> one</td></tr>
    <tbody style="color: yellow;">
        <tr><td> two</td></tr>
        <tr><td> three</td></tr>
    </tbody>
    <tbody style="color: red;">
        <tr><td> four </td></tr>
    </tbody>
</table>

Test case .

关于html - 在 div 中包含 td,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5978400/

相关文章:

html - 文本输入和按钮输入在同一行

javascript - 简单页面的奇怪 CSS/div 间距问题

html - 在段落中间创建一段动态文本

html - 在记事本中获取页面生成的源代码

html - 可以使用背景颜色更改背景,但不能更改背景图像

html - float div 上的框阴影

javascript - 轮播只是将图像上传到网站而无需更改它们

javascript - 使用 ng-repeat 有条件地应用过滤器

html - 如果选中,更改复选框的图像背景

html - 容器中的中心网格元素(960 网格)