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

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 在application.css.scss中的Require语句前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想使用灯箱宝石,如fancybox或彩盒.两个宝石要求在application.css中添加这一行
  1. *= require colorBox-rails

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

“*”后无效的CSS:expected“{”,was“= require colorb …”

这是完整的application.css.scss

  1. @import "bootstrap";
  2. @import "welcome";
  3. @import "sessions";
  4. @import "users";
  5.  
  6.  
  7. *= require colorBox-rails

解决方法

application.css.scss或application.css是一样的.只需将你的application.css重命名为application.css.scss.

对于添加该行,它需要在顶部,在评论中.喜欢这个:

  1. /*
  2. * This is a manifest file that'll be compiled into application.css,which will include all the files
  3. * listed below.
  4. *
  5. * 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.
  6. *
  7. * You're free to add application-wide styles to this file and they'll appear at the bottom of the
  8. * compiled file so the styles you add here take precedence over styles defined in any styles
  9. * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
  10. * file per style scope.
  11. *
  12. *= require_self
  13. *= require colorBox-rails
  14. */
  15.  
  16. @import "bootstrap";
  17. @import "welcome";
  18. @import "sessions";
  19. @import "users";

猜你在找的Ruby相关文章