Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.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 在没有复制设置的情况下,如何在两个类中应用这些CSS?_Html_Css_Xhtml - Fatal编程技术网

Html 在没有复制设置的情况下,如何在两个类中应用这些CSS?

Html 在没有复制设置的情况下,如何在两个类中应用这些CSS?,html,css,xhtml,Html,Css,Xhtml,我对CSS有以下问题 在我的CSS文件中,我有如下内容: table.standard-table-cls tbody tr td a { font: 11px Verdana, Geneva, Arial, Helvetica, sans-serif; text-decoration:none; color:#76818a; } 这意味着设置将应用于表内的所有tbody tr td a,具有类标准表cls 好的,我需要将此设置也应用于表中的所有主体tr td

我对CSS有以下问题

在我的CSS文件中,我有如下内容:

table.standard-table-cls tbody tr td a {    
    font: 11px Verdana, Geneva, Arial, Helvetica, sans-serif;
    text-decoration:none;
    color:#76818a;
}
这意味着设置将应用于表内的所有tbody tr td a,具有类标准表cls

好的,我需要将此设置也应用于表中的所有主体tr td a,具有类标准表cls内部libretto

我该怎么做才能在这个table类中应用这个设置呢

我知道我可以用这种方式复制CSS

table.standard-table-cls-inner-libretto tbody tr td a { 
    font: 11px Verdana, Geneva, Arial, Helvetica, sans-serif;
    text-decoration:none;
    color:#76818a;
}

但是我可以不复制它就做这件事吗。首先,您“可以”(参见下面的注释)简化您的CSS规则:

这:
table.standard-table-cls tbody tr td a{…}

“可能”更改为:
.standard table cls tbody td a{…}

2。其次,要将其应用于第二个规则集,请使用逗号:

.standard table cls tbody td a、.standard table cls inner libretto tbody td a{…}

3。如果您想更时髦一点,尽管在规则实现方面通常没有那么高效,您可以这样做,例如:

[class*=标准表cls]tbody td a{…}
将应用于这两种情况


注意。上面对HTML/CSS的结构做了一些相当现实的假设,希望这就是您想要的

table.standard-table-cls tbody tr td a, table.standard-table-cls-inner-libretto tbody tr td a{    
font: 11px Verdana, Geneva, Arial, Helvetica, sans-serif;
text-decoration:none;
color:#76818a;
}

必须用逗号分隔规则:
table.standard-table-cls tbody tr td a,table.standard-table-cls-inner-libretto tbody tr td a{…}
。第2部分是答案。第1部分中的简化更改了规则的含义,因为原始规则不适用于
th
元素中的
a
元素。这条规则很有可能在许多方面得到简化,但我们无法真正知道,这与所问的问题无关。@JukkaK.Korpela-因此,
nb
。这可能与所问的问题无关,但我始终认为添加一点额外的信息有助于学习体验,我想我喜欢这样认为,这可能是一点教学以及二进制问答。不管怎样,如上所述。