Rails 3.1 Load css in particular order

☆樱花仙子☆ 提交于 2019-12-17 17:49:06

问题


I see that in development environment in rails 3.1 the css are loaded in alphabetic order and not in the order I want. I want a particular css file to be at the end so it over-writes any styles given to the class before. How can we achieve that?


回答1:


It is better to specify the order of each and every files manually:

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



回答2:


You can actually do something like:

/* 
 *= require 'reset'
 *= require_self
 *= require_tree .
*/

in your application.css file. This allows you to specify any number of stylesheets, such as a reset, to come before the tree without having to specify each individual file. The single quotes around reset are optional.

Not trying to resurrect an old thread, just thought this might be helpful for some.



来源:https://stackoverflow.com/questions/8890929/rails-3-1-load-css-in-particular-order

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!