首页 > 解决方案 > 为什么我的 scss 不采用通用选择器?

问题描述

我正在学习 Sass,我选择尝试使用 Scss 语法,但是当我尝试将 scss 代码编译为 css 时出现错误。

这是命令行的错误:


> starter@1.0.0 compile:sass C:\Users\xxx
> node-sass sass/main.scss css/style.css

{
  "status": 1,
  "file": "C:/Users/xxx/sass/main.scss",
  "line": 14,
  "column": 1,
  "message": "Invalid CSS after \"*\": expected expression (e.g. 1px, bold), was \",\"",
  "formatted": "Error: Invalid CSS after \"*\": expected expression (e.g. 1px, bold), was \",\"\n        
  on line 14 of sass/main.scss\n>> *,\r\n   ^\n"
}

这是我的 Scss 文件:

*,
*::after,
*::before {
  margin: 0;
  padding: 0;
  box-sizing: inherit; 
}

html{
    font-size: 62.5%;
}

body{
    font-family: "Lato", sans-serif;
    font-weight: 400;
    font-size: 1.6rem;
    line-height: 1,7;
    color: #777;
    padding: 3rem;
    box-sizing: border-box;
} 

我正在通过 Package.json 运行它:

{
  "name": "starter",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "compile:sass": "node-sass sass/main.scss css/style.css"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "node-sass": "^4.14.1"
  }
}

出于某种原因,它说通用选择器不是 Css 代码,我尝试通过将该选择器注释掉,但它对 html 选择器说同样的话。

-------UPDATE------- 一旦我使用了 7-1 css 架构,错误就停止了。当我将通用选择器放在另一个文件中时,它被接受了,所以问题得到了解决,但我不知道为什么。

标签: csssass

解决方案


推荐阅读