application.css.scss中的Require语句 [英] Require statement in application.css.scss
问题描述
我想使用灯箱上的宝石,例如fancybox或color box。这两个宝石都要求在application.css
中添加这一行。 $ c>这是问题所在。我只有application.css.scss文件。我所有的css文件都是scss文件。我在application.css.scss中有导入语句,但是没有* = require语句。添加以上行会导致错误:
*后的CSS无效:预期的 {,是 = require colorb ...
这是完整的application.css.scss
@import bootstrap;
@import欢迎;
@import会话;
@import用户;
* =需要colorbox-rails
application.css.scss
或 application.css
差不多。只需将您的 application.css
重命名为 application.css.scss
。
关于添加该行,它需要在注释的右上方。像这样:
/ *
*这是一个清单文件,将被编译成application.css,将包括下面列出的所有文件
*。
*
*此目录中的任何CSS和SCSS文件,lib / assets / stylesheets,vendor / assets / stylesheets,
*或插件的vendor / assets / stylesheets(如果有)都可以这里使用相对路径引用。
*
*您可以随意在该文件中添加应用程序范围的样式,它们将显示在
*编译文件的底部,因此您在此处添加的样式优先于样式以该目录中其他CSS / SCSS文件中定义的任何样式
*定义。通常最好为每个样式范围创建一个新的
*文件。
*
* = require_self
* =需要colorbox-rails
* /
@import bootstrap;
@import欢迎;
@import会话;
@import用户;
I want to use a lightbox gem such as fancybox or color box. Both gems ask to add this line in the application.css
*= require colorbox-rails
Here's the problem. I only have application.css.scss files. All my css files are scss files. I have import statements in the application.css.scss but no *=require statements. Adding the above line results in the error :
Invalid CSS after "*": expected "{", was "=require colorb..."
Here's the complete application.css.scss
@import "bootstrap";
@import "welcome";
@import "sessions";
@import "users";
*= require colorbox-rails
application.css.scss
or application.css
are kinda the same. Just rename your application.css
to application.css.scss
.
As for adding that line, it'll need to be right up the top, in a comment. Like this:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_self
*= require colorbox-rails
*/
@import "bootstrap";
@import "welcome";
@import "sessions";
@import "users";
这篇关于application.css.scss中的Require语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!