2014-02-13 35 views
0

恢复@extend我想@extend在一定的条件和其他条件的类撤销该@extend在SASS

<div class="myclass"> 
<div class="not_special"> 
</div> 
</div> 

所以当没有.not_special孩子这将是

.myclass 
    @extend .special 

而且当有.not_special孩子

.myclass:has(.not_special) 
    //revoke the previous @extend 

我不能使用JavaScript来,因为即使添加或删除类TS都没有明确的规定,因为可能有许多事件和捕捉他们都不可能

+0

可能复制[有什么方法可以在SASS中“取消”一个类?](http://stackoverflow.com/questions/12505378/is-there-any-way-to-unextend-a-class-in-sass) – cimmanon

回答

4

使用:not伪类

.myclass:not:has(.not_special) 
    @extend .special 

这将适用于@extend所有.myclass除非他们有一个孩子.not_special

+0

这将引用.myclass.not_special,我需要样式.myclass不具有孩子.not_sp ecial –

+0

对不起 - 我误解了你的更新,所以现在答案应该工作 – fcalderan