css - rake assets:precompile > Sass::SyntaxError: Invalid CSS after "padding": expected ";"是 ":20px;"

标签 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;
}

如何解决?

最佳答案

如错误所述,它紧接在您的背景之后:#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;
}

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

Background - Shorthand property To shorten the code, it is also possible to specify all the background properties in one single property. This is called a shorthand property.

The shorthand property for background is background:

Example body { background: #ffffff url("img_tree.png") no-repeat right top; }

关于css - rake assets:precompile > Sass::SyntaxError: Invalid CSS after "padding": expected ";"是 ":20px;",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53499396/

相关文章:

html - 卡住网站表格的首行

jquery - Cycle2 和 Firefox 图像闪烁

ruby-on-rails - 带有 Java7 的 JRuby 通过代理搞砸了 HTTPS 数据

ruby - 为什么我在 irb 1.9.3 中从 method_missing 得到 "stack level too deep"?

ruby-on-rails - rails : How to get a model to "inherit" attributes from a parent model?

css - 如何在cordova元素中添加基本的UI组件?

javascript - 以前选择的日期不会在日历中取消选择

ruby - 为什么 block 不像方法那样继承调用者的 $SAFE 级别?

ruby-on-rails - 当父级保存失败时引发异常

ruby-on-rails - 嵌套模型和父验证