Rails 3.1按特定顺序加载css

时间:2012-01-17 07:16:39

标签: ruby-on-rails css ruby-on-rails-3.1

我看到在rails 3.1的开发环境中,css是按字母顺序加载的,而不是按照我想要的顺序加载。我想要一个特定的css文件在最后,所以它覆盖了之前给予类的任何样式。我们怎样才能做到这一点?

2 个答案:

答案 0 :(得分:40)

您实际上可以执行以下操作:

/* 
 *= require 'reset'
 *= require_self
 *= require_tree .
*/
在您的application.css文件中

。这允许您在树之前指定任意数量的样式表(例如重置),而无需指定每个单独的文件。复位周围的单引号是可选的。

没有尝试复活旧线程,只是认为这可能对某些人有用。

答案 1 :(得分:18)

最好手动指定每个文件的顺序:

/*
 * This is a manifest file that'll automatically include all the stylesheets available in this directory
 * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
 * the top of the compiled file, but it's generally better to create a new file per style scope.
 *= require_self
 *= require reset
 *= require groups
 *= require the_last
*