rake asset:precompile> Sass :: SyntaxError:“ padding”之后的CSS无效:预期的“;”为“:20px;”

时间:2018-11-27 12:10:21

标签: css ruby-on-rails ruby sass asset-pipeline

我在跑步

rake assets:precompile RAILS_ENV=staging

然后我得到此错误堆栈:

rake aborted!
Sass::SyntaxError: Invalid CSS after " padding": expected ";", was ":20px;"
(sass):5108
/home/ubuntu/auto_ful/path/ruby/2.3.0/gems/sass-3.5.6/lib/sass/scss/parser.rb:1278:in `expected'
/home/ubuntu/auto_ful/path/ruby/2.3.0/gems/sass-3.5.6/lib/sass/scss/parser.rb:1208:in `expected'
/home/ubuntu/auto_ful/path/ruby/2.3.0/gems/sass-3.5.6/lib/sass/scss/parser.rb:1203:in `tok!'
/home/ubuntu/auto_ful/path/ruby/2.3.0/gems/sass-3.5.6/lib/sass/scss/parser.rb:804:in `block in try_declaration'
/home/ubuntu/auto_ful/path/ruby/2.3.0/gems/sass-3.5.6/lib/sass/scss/parser.rb:1254:in `rethrow'
/home/ubuntu/auto_ful/path/ruby/2.3.0/gems/sass-3.5.6/lib/sass/scss/parser.rb:809:in `try_declaration'
/home/ubuntu/auto_ful/path/ruby/2.3.0/gems/sass-3.5.6/lib/sass/scss/parser.rb:732:in `declaration_or_ruleset'
/home/ubuntu/auto_ful/path/ruby/2.3.0/gems/sass-3.5.6/lib/sass/scss/parser.rb:697:in `block_child'

但是随后我尝试使用此方法来追溯错误的确切位置:

sass -c app/assets/stylesheets/**.css*

我收到以下错误消息:

Error: Invalid CSS after "#f0f0f0": expected expression (e.g. 1px, bold), was ";"
        on line 18 of app/assets/stylesheets/ajax-bootstrap-select.css

我在ajax-bootstrap-select.css中的CSS是

.bootstrap-select .status {
  background: #f0f0f0;
  clear: both;
  color: #999;
  font-size: 11px;
  font-style: italic;
  font-weight: 500;
  line-height: 1;
  margin-bottom: -5px;
  padding: 10px 20px;
}

如何解决?

2 个答案:

答案 0 :(得分:1)

错误状态指出,它紧随您的背景:#f0f0f0行:

https://www.w3schools.com/css/css_background.asp

如果您要更改的是背景色,请尝试:

.bootstrap-select .status {
  background-color: #f0f0f0;
  clear: both;
  color: #999;
  font-size: 11px;
  font-style: italic;
  font-weight: 500;
  line-height: 1;
  margin-bottom: -5px;
  padding: 10px 20px;
}

您只是在使用背景,它是一次输入各种背景属性的简写:

  

背景-简写属性要缩短代码,它也是   可以一次指定所有背景属性   属性。这称为速记属性。

     

背景的简写属性是背景:

     

示例正文{       背景:#ffffff url(“ img_tree.png”)不重复右上方; }

答案 1 :(得分:0)

在Rails 5中似乎发生了此错误。我刚运行rake assets:precompile,它编译成功,没有错误。