通过使用属性选择器嵌套来附加到类名

时间:2015-04-07 14:05:27

标签: sass

我有以下sass:

.list {
    &__button{
        cursor:pointer;
        display: block;
        padding: 4px;
        border:1px solid $color4;
        outline: none;
        &__square {
            border: 1px solid $color1;
            width:12px;
            height:12px;
        }

        &__text {       
            padding-right: 5px;
            color: red;
        }
    }

    &__button[state-selected="true"] {
        .list__button__text {       
            color       : $color1;
        }
    }
}

我必须使用该类的全名来使这部分工作:

&__button[state-selected="true"] {
    .list__button__text {       
        color       : $color1;
    }
}

有没有办法简化这部分?类似的东西:

&__button[state-selected="true"] {
    &__text {       
        color       : $color1;
    }
}

但是这会出错:“& __ text”的父选择器无效:“。list__button [state-selected =”true“]”。

0 个答案:

没有答案
相关问题