<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 7 年前。
<分区>
编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
关闭 7 年前。
我已经设置了标记。这是 link .
我无法弄清楚如何单独选择表格中的表格。我需要使用 :nth 选择器选择嵌套表的 tr
和 td
。
最佳答案
根据您的标记,以下 CSS 应该可以满足您的需求。如果我正确阅读了你的问题,那就是......
table tr:nth-child(4) td:nth-child(1) table{background-color:#f0f;}
table tr:nth-child(4) td:nth-child(2) table{background-color:#0ff;}
这将选择包含两个内部表格的表格行,然后选择每个表格。
更好的方法当然是使用带有 ID/类名称的 div。表格应该用于表格数据,而不是布局。
你的 fiddle已更新
关于CSS3 使用 :nth selectors 选择嵌套表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32196808/