ruby-on-rails - 在application.css.scss中的Require语句

标签 ruby-on-rails sass fancybox colorbox

我想使用灯箱上的 gem ,例如fancybox或color box。两个 gem 都要求在application.css中添加这一行

 *= require colorbox-rails

这是问题所在。我只有application.css.scss文件。我所有的css文件都是scss文件。我在application.css.scss中有导入语句,但是没有* = require语句。添加以上行会导致错误:

“*”后的CSS无效:预期的“{”,是“= require colorb ...”

这是完整的application.css.scss
@import "bootstrap";
@import "welcome";
@import "sessions";
@import "users";


*= require colorbox-rails

最佳答案

application.css.scssapplication.css差不多。只需将application.css重命名为application.css.scss即可。

至于添加这一行,它需要在注释的顶部。像这样:

/*
 * 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";

关于ruby-on-rails - 在application.css.scss中的Require语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26171159/

相关文章:

css - Vue 3 (CLI) 多次导入全局样式

javascript - fancybox jQuery 中的 Aftershow

javascript - Fancybox 在页面中途加载

ruby-on-rails - 将散列更改为数组

ruby-on-rails - Rails 应用程序 Controller 中的“protect_from_forgery”

ruby-on-rails - ArticlesController 中的 ActiveRecord::RecordNotFound#show 找不到带有 'id' 的文章 =edit

html - Angular CLI 组件和指令 CSS/SASS 属性和变量

ruby-on-rails - Rails 无意中在 View 中显示 JSON

css - 有没有办法一次为 2 个 css 属性分配相同的值?

jquery - Fancybox onClosed 函数在盒子打开之前发生?