当我使用样式CSS时,如下所示:
#test p{/*css code here*/}
#test span{/*css code here*/}
#test p.one{/*css code here*/}
#test span.test{/*css code here*/}
Run Code Online (Sandbox Code Playgroud)
然后#test每次选择带有id的div 更容易,如下所示:
begin #test
p{/*css code here*/}
span{/*css code here*/}
p.one{/*css code here*/}
span.test{/*css code here*/}
end #test
Run Code Online (Sandbox Code Playgroud)
这是CSS样式的好习惯吗?如果是这样,我希望这将被添加到CSS的未来版本中.
或者您可以使用动态CSS语言,例如LESS:http://lesscss.org/ OR Sass http://sass-lang.com/ as @steveax指出