2014-10-29 6 views
0

나는 다음과 같은 CSS :afterCSS의 제거는

<div class="bob"></div> 

.bob:after{ 
    background:#ff0000; 
    height:10px; 
    width:10px; 
} 

를 그냥 두 번째 클래스를 사용 후 그것을 제거 할 수 있다고 가정 해?

<div class="bob geff"></div> 

.bob:after{ 
    background:#ff0000; 
    height:10px; 
    width:10px; 
} 

.bob.geff:after{ 
    background:none; 
    height:0px; 
    width:0px; 
} 

답변

1

귀하의 :after 당신이 그것을 content을 지정하지 않는 한 영향을주지 않습니다. 콘텐츠의 기본값은 none이므로

.bob:after{ 
    content:''; 
    background:#ff0000; 
    display: inline-block; 
    height:10px; 
    width:10px; 
} 

.bob.geff:after{ 
    content: none; 
} 

이 작동해야합니다. fiddle

+0

좋은 답변은 제 답변보다 훨씬 포괄적입니다. – Nenotlep