2014-05-14 59 views
2

我有兩個CSS表達式:這兩個CSS表達式有什麼區別?

.firstexpression.secondexpression (without space) 

.firstexpression .secondexpression (with space) 

的區別是什麼?

+0

請參閱:http://stackoverflow.com/questions/10036156/whats-the-difference-between-css-classes-foo-bar-without-space-and-foo-bar,http:// stackoverflow .com/questions/1126338/class-class-class-class-class-class-in-css,http://stackoverflow.com/questions/14763313/whats-the-difference-between-these-two-css -selectors?RQ = 1 –

回答

7

第一適用於具有施加,第二個的子元素與.secondexpression與父兩個類元素與.firstexpression

.firstexpression.secondexpression{ 
    /* styles */ 
} 

適用於:

<div class='firstexpression secondexpression'>Applies to this element</div> 

Vs的..

.firstexpression .secondexpression{ 
    /* styles */ 
} 

適用於:

<div class='firstexpression'> 
    <div class='secondexpression'>Applies to this element only</div> 
</div>