Hallo, ich habe folgendes Problem:
?Beim Definieren von CSS-Farben ist eine at-Regel oder ein Selektor erforderlich.“
Ich verwende VS-Code und habe das CSS unter https://jigsaw.w3.org/css-validator/validator#css überprüftIch wei? nicht, was das Problem ist!
/* Color Variables */ $red: red; $green: green; $orange: orange; $blue: blue; $purple: purple; $white: white; $black: black; $bg: /* #eff3f6 */ #e3e5e6; $darkgray-blue: #354052; $lightgray-blue: #7f8fa4; /* Styles */ body { background: $bg; font-family: 'Roboto', sans-serif; letter-spacing: 1px; } .text-red {color: $red !important;} .text-green {color: $green !important;} .text-orange {color: $orange !important;} .text-blue {color: $blue !important;} /* buttons */ .btn-red { background: $red; color: $white; font-size: xx-small; &:hover, &:focus { background: darken($red, 8%); color: white; }
CSS 驗(yàn)證器似乎有某種錯(cuò)誤。如果您刪除 /* Color Variables */
注釋或注釋本身之前的空格,它會向您顯示錯(cuò)誤 - 正如它應(yīng)該的那樣,因?yàn)檫@不是 CSS。
您正在使用 Sass 變量、規(guī)則語法和函數(shù)。您應(yīng)該將文件命名為 style.scss
而不是 style.css
來向大多數(shù)工具表明您的意圖,如果您尚未配置 Sass 構(gòu)建,則需要要做到這一點(diǎn)。具體如何取決于您的工具的其余部分,但無論如何,都會有一個(gè)插件(例如 webpack 的 sass 加載器)。