css 嵌套样式规则不能以 类型选择器 作为开头

404 阅读1分钟
.container {
    span {
        color: red;
    }
}

上面这段代码在build的时候会警告:

[WARNING] A nested style rule cannot start with "span" because it looks like the start of a declaration [css-syntax-error]

改成以下代码不会警告:

.container {
    & span {
        color: red;
    }
}

原因:css 嵌套样式规则不能以类型选择器作为开头