错误:“body”之后的无效 CSS:预期的选择器或规则,在第 4 行是“”
Posted
技术标签:
【中文标题】错误:“body”之后的无效 CSS:预期的选择器或规则,在第 4 行是“”【英文标题】:Error: Invalid CSS after "body ": expected selector or at-rule, was "" on line 4错误:“body”之后的无效 CSS:预期的选择器或规则,在第 4 行是“” 【发布时间】:2018-11-20 14:45:30 【问题描述】:我正在 style.scss 中编写以下代码:body margin-top:105px;,我从我的 sass 编译器(考拉)和 style.scss 中收到此错误消息
错误:“body”后的 CSS 无效:预期的选择器或 at-rule,是 “” 在 C:\Users\Petar\Desktop\Mizuxe novo\scss\style.scss 的第 4 行
我是这一切的初学者,所以如果您需要更多信息,请询问
https://codepen.io/petar-scepanovic/pen/Papmxj
/*
Error: Invalid CSS after "body ": expected selector or at-rule, was ""
on line 4 of C:\Users\Petar\Desktop\Mizuxe novo\scss\style.scss
1: $primary: #3292a6;
2: $primary-overlay:rgba(50,146,166, 0.8)
3:
4: body
5: margin-top:105px;
6:
7:
8:
9: .navbar
Backtrace:
C:\Users\Petar\Desktop\Mizuxe novo\scss\style.scss:4
C:/Program Files (x86)/Koala/rubygems/gems/sass-3.5.2/lib/sass/scss/parser.rb:1278:in `expected'
C:/Program Files (x86)/Koala/rubygems/gems/sass-3.5.2/lib/sass/scss/parser.rb:1208:in `expected'
C:/Program Files (x86)/Koala/rubygems/gems/sass-3.5.2/lib/sass/scss/parser.rb:42:in `parse'
C:/Program Files (x86)/Koala/rubygems/gems/sass-3.5.2/lib/sass/engine.rb:414:in `_to_tree'
C:/Program Files (x86)/Koala/rubygems/gems/sass-3.5.2/lib/sass/engine.rb:290:in `render'
C:/Program Files (x86)/Koala/rubygems/gems/sass-3.5.2/lib/sass/exec/sass_scss.rb:400:in `run'
C:/Program Files (x86)/Koala/rubygems/gems/sass-3.5.2/lib/sass/exec/sass_scss.rb:63:in `process_result'
C:/Program Files (x86)/Koala/rubygems/gems/sass-3.5.2/lib/sass/exec/base.rb:52:in `parse'
C:/Program Files (x86)/Koala/rubygems/gems/sass-3.5.2/lib/sass/exec/base.rb:19:in `parse!'
C:/Program Files (x86)/Koala/rubygems/gems/sass-3.5.2/bin/sass:13:in `<top (required)>'
C:/Program Files (x86)/Koala/bin/sass:22:in `load'
C:/Program Files (x86)/Koala/bin/sass:22:in `<main>'
*/
body:before
white-space: pre;
font-family: monospace;
content: "Error: Invalid CSS after \"body \": expected selector or at-rule, was \"\"\A on line 4 of C:\Users\Petar\Desktop\Mizuxe novo\scss\style.scss\A \A 1: $primary: #3292a6;\A 2: $primary-overlay:rgba(50,146,166, 0.8)\A 3: \A 4: body \A 5: margin-top:105px;\A 6: \A 7: \A 8: \A 9: .navbar ";
【问题讨论】:
$primary-overlay:rgba(50,146,166, 0.8);
后面缺少分号
【参考方案1】:
您只是在 CSS 的第 2 行漏掉了一个分号。
变化:
$primary-overlay:rgba(50,146,166, 0.8)
到:
$primary-overlay:rgba(50,146,166, 0.8);
完成了!
【讨论】:
非常感谢!你为我节省了很多时间:)以上是关于错误:“body”之后的无效 CSS:预期的选择器或规则,在第 4 行是“”的主要内容,如果未能解决你的问题,请参考以下文章
css选择器nth-child(1),first-child在加入别的标签,为啥会失效?这两段代
EasyMock失败的测试用例“无效使用参数匹配器! 2匹配预期,1记录“错误