选择性造型css3

0 html css html5 css3

这是我的代码:

<table width="562" cellspacing="0" cellpadding="0" border="0" align="center" class="genericClass">
     Some nested tags
</table>
Run Code Online (Sandbox Code Playgroud)

我的风格是:

table.genericClass  a { ...  } 
table.genericClass  p,li,div,td {}
Run Code Online (Sandbox Code Playgroud)

但是,所有的div,p以及所有列出的标签越来越以上未提及预期的样式.我的语法错了吗?

Ion*_*ula 5

现在你选择所有div,litd从DOM的.如果要将样式仅添加到表中的元素,genericClass则应使用类代码:

table.genericClass a {
  /**your properties and values here**/
} 
table.genericClass p,
table.genericClass li,
table.genericClass div,
table.genericClass td {
  /**your properties and values here**/
}
Run Code Online (Sandbox Code Playgroud)

或者,如果您想单独设置它们的样式:

table.genericClass p{
  /**your properties and values here**/
}
table.genericClass li{
  /**your properties and values here**/
}
table.genericClass div{
  /**your properties and values here**/
}
table.genericClass td {
  /**your properties and values here**/
}
Run Code Online (Sandbox Code Playgroud)