<span class="bigsize stress">膽小如鼠</span> 與 <span class="stress bigsize">膽小如鼠</span>效果一樣
生效順序與css中樣式價(jià)值順序有關(guān),與class list中順序無關(guān)
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>css</title> <style type="text/css"> .colorred{color:red;} .colorgreen{color:green;} </style> </head> <body> <p><span class="colorred colorgreen">colorred colorgreen</span></p> <p><span class="colorgreen colorred">colorgreen colorred</span></p> </body> </html>
執(zhí)行下這個代碼就知道了,都是green的
2014-08-06
你的回答是完全錯誤的,你自己試試就知道了,永遠(yuǎn)是css順序中后面的".bigsize"的生效,顯示red
2015-06-16
這個案例很經(jīng)典,一個元素有2個CLASS,而且CLASS有相同屬性的時候,屬性值由最后一個決定“就近原則”
2014-10-04
多看看會知道更多惹?(????)
2014-08-06
執(zhí)行下這個代碼就知道了,都是green的
2014-08-06
親,是這樣的,但是記住,如果stress與bigsize中有設(shè)置相同的css樣式屬性,如.stress{color:red;}.bigsize{color:green;},后面的會覆蓋前面的,
<span class="bigsize stress">膽小如鼠</span>就會顯示red
<span class="stress bigsize">膽小如鼠</span>就會顯示green