How do i get the same object with a class in SCSS?

2020-02-16 01:41发布

I have this code:

input[type="text"] {
    color: red;
    .blue {
        color: blue;
    }
}

That gives me this

input[type="text"] {
    color: red
}
input[type="text"] .blue {
    color: blue;
}

How do I get something like this?

input[type="text"] {
    color: red
}
input[type="text"].blue {
    color: blue;
}

标签: css ruby sass
1条回答
Explosion°爆炸
2楼-- · 2020-02-16 02:26

You're looking for the parent selector (&):

input[type="text"] {
    color: red;
    &.blue {
        color: blue;
    }
}
查看更多
登录 后发表回答