html - 如何将表行嵌套在表列中?

标签 html

我正在使用表格以表格格式输出一些数据。 (下面只是我实际使用的一个小例子)我正在尝试创建一个 2 列布局。两列都将包含表格行。但是我正在尝试将它们都创建为 td 作为表行的容器。

我的代码是这样的

    <table>

<tr>


    <td>
    <tr><td>I am nested in a table column </td><td>I am also nested in a table column  </td></tr>
    </td>


    <td>
    <tr><td>I am nested in the second table column </td><td>I am also nested the second table column  </td></tr>
    </td>


</tr>


</table>

但由于某种原因,浏览器以不同的方式呈现它......

有人可以帮我让浏览器按照我写的 HTML 代码显示它吗?谢谢!

<table>

<tr>


    <td>
    <tr><td>I am nested in a table column </td><td>I am also nested in a table column  </td></tr>
    </td>


    <td>
    <tr><td>I am nested in the second table column </td><td>I am also nested the second table column  </td></tr>
    </td>


</tr>


</table>

最佳答案

试试这个:

<table>
<tr>
    <td>
    <table>
        <tr>
        <td>I am nested in a table column</td>
        <td>I am also nested in a table column</td>
        </tr>
        <tr>
        <td>I am nested in the second table column</td>
        <td>I am also nested the second table column</td>
        </tr>
    </table>
    </td>
</tr>
</table>

Working fiddle .

关于html - 如何将表行嵌套在表列中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24719724/

相关文章:

javascript - jQuery 类不会添加更改选择框的选项

html - CSS 兄弟选择器没有动画

html - 如何在已设置为另一种颜色的情况下更改列表中 anchor 标记的颜色以使其处于事件状态?

css - 使内容 <DIV> 填充具有可变高度标题的容器

html - 如何清除上面 2 个 div 中的第三个 div?

html - 有人可以帮忙弄清楚我在 testdome 上的回答有什么问题吗?

html - 如何使用 CSS 控制光标/插入符大小

css - 缩放 HTML 布局

html - CSS 位置 Sticky 和 ​​Z-Index overlay/modal

html - 页脚中的中心(圆圈)Div