Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 祖先表类影响后续表元素_Html_Css - Fatal编程技术网

Html 祖先表类影响后续表元素

Html 祖先表类影响后续表元素,html,css,Html,Css,有人能告诉我如何解决祖先表类影响后续表元素的问题吗 我有一张桌子在桌子上: <table id="table1" class='parent'> <tr> <td> <table style="width: 100%"> <tr> <td> </td>

有人能告诉我如何解决祖先表类影响后续表元素的问题吗

我有一张桌子在桌子上:

<table id="table1" class='parent'>
    <tr>
        <td>
            <table style="width: 100%">
                <tr>
                    <td>

                    </td>
                </tr>
                <tr>
                    <td>

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

        </td>
    </tr>
</table>
这将导致表2 tr:first child td:first child也将获得

width: 100%;
height: 30px;
border: dashed red 1px;
如何避免这种情况并仅为父表设置css,而不影响后续表元素

使用“>”不为嵌套表应用样式

#table1>tr:first-child>td:first-child


请仔细编排你的问题。您还应该包括您的实际标记,因为它与您的CSS不匹配,而且据我们所知,问题可能完全存在于其他地方。我已经试过了。父表中的第一个td不会以这种方式获得格式。可能您的代码上丢失了标记。请检查浏览器开发工具中的HTML#表1>tbody>tr:first child>td:first Childaaah,该死的解决了所有问题。我在用html代码制作表格时从不使用它,因为制作表格不需要它。但是很明显,像这样的css目标需要它。无论如何,非常感谢你
#table1>tr:first-child>td:first-child
#table1>tbody>tr:first-child>td:first-child