CSS上是否有规则确定在元素上定义多个类时的级联顺序?(class="one two"vs class="two one")
class="one two"
class="two one"
目前,似乎没有这种效果。
示例:两个div在Firefox上均为橙色
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <style> .one { border: 6px dashed green } .two { border: 6px dashed orange } </style> </head> <body> <div class="one two"> hello world </div> <div class="two one"> hello world </div>
这取决于在样式表中最后声明的那个。例如,
.one { border: 6px dashed green } .two { border: 6px dashed orange }
与
.two { border: 6px dashed green } .one { border: 6px dashed orange }