Html Rails 上的 SASS 无效 CSS 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21140438/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:30:38  来源:igfitidea点击:

SASS Invalid CSS error on Rails

htmlcssruby-on-railstwitter-bootstrapsass

提问by Leo Costa

I'm trying to use http://startbootstrap.com/stylish-portfolioin my rails app however I'm getting the following error in my stylish-portfolio.css.scss.erb file:

我正在尝试在我的 rails 应用程序中使用http://startbootstrap.com/stylish-portfolio但是我在我的 fashion-portfolio.css.scss.erb 文件中收到以下错误:

ActionView::Template::Error (Invalid CSS after "body ": expected selector or at-rule, was "{"

This is my css file:

这是我的 css 文件:

@import 'bootstrap'

/* Global Styles */

html,
body {
  height: 100%;
  width: 100%;
}

.vert-text {
  display: table-cell;
  vertical-align: middle;
  text-align: center;
}

.vert-text h1 {
  padding: 0;
  margin: 0;
  font-size: 4.5em;
  font-weight: 700;
}

...

...

回答by lime

My guess is that you are missing a semicolon in the stylish-portfolio.css.scss.erbfile, maybe after an SCSS variable definition?

我的猜测是您在stylish-portfolio.css.scss.erb文件中缺少分号,也许在 SCSS 变量定义之后?

Here's the original CSS fileI assume you are basing this on, maybe you want to do a diffbetween that and yours to determine what has changed.

这是我假设您基于此的原始 CSS 文件,也许您想diff在它和您的文件之间做一个以确定发生了什么变化。



Edit:Yup, apparently there is a missing semicolon after the first line. The @importstatement

编辑:是的,显然在第一行之后缺少一个分号。该@import声明

@import 'bootstrap'

should instead be

应该是

@import 'bootstrap';

since you are using the .scssextension. You can omit the semi-colon if you are using the .sassextension.

因为您正在使用.scss扩展程序。如果使用.sass扩展名,则可以省略分号。