<styletype="text/css">.important{font-weight:bold;}.warning{font-style:italic;}/*.important和.warning之间不能有空格*//*.warning.important {background:silver;}颠倒顺序执行结果不变*/.important.warning{background:silver;}</style><pclass="important">This paragraph is very important.</p><pclass="warning">This is a warning.</p><pclass="important warning">This paragraph is a very important warning.</p>
执行结果:
例2:3个类
注:如果一个多类选择器包含类名列表中没有的一个类名,匹配就会失败。
<style>.important{font-weight:bold;}.warning{font-style:italic;}/*.important和.warning之间不能有空格*//*.warning.important {background:silver;}颠倒顺序执行结果不变*/.important.warning{background:silver;}</style><pclass="important">This paragraph is very important.</p><pclass="warning">This is a warning.</p><pclass="important urgent warning">This paragraph is a very important warning.</p>