如何在Rails 3.1中加载CSS框架?
|
我正在尝试将CSS框架Blueprint加载到我的Rails 3.1应用程序中。
在Rails 3.0+中,我的views / layouts / application.html.erb中会有类似的内容:
<%= stylesheet_link_tag \'blueprint/screen\', \'application\' %>
<%= stylesheet_link_tag \'blueprint/print\', \'media\' => \'print\' %>
<!--[if lt IE 8]>
<%= stylesheet_link_tag \'blueprint/ie\' %>
<![endif]-->
但是,Rails 3.1现在使用SASS。加载这些Blueprint CSS文件的正确方法是什么?
目前,我在app / assets / stylesheets /中有蓝图目录
我的应用程序/资产/样式表/application.css如下所示:
/*
* 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_tree .
*/
我应该对application.css做些什么,以便它加载必要的蓝图文件吗?如果是这样,怎么办?
其次,如何提供某种条件来检查IE8,以加载blueprint / ie.css?
编辑:
嗯,请重新加载应用程序的网页。 Rails 3.1确实包含了蓝图文件。即使css文件位于文件夹中(在这种情况下:app / assets / stylesheets / blueprint。)
这给我两个问题
如何使用SASS应用if lt IE 8条件?
如何使用SASS加载打印格式的CSS文件(即<%= stylesheet_link_tag \'blueprint / print \',\'media \'=> \'print \'%>)?
没有找到相关结果
已邀请:
7 个回复
眠皇
中的文件仍然可以放心使用。 如果要激活SASS解析器(并使用新框架),请将
重命名为
,并将其放在
文件夹中。然后在取消注释require_self / require_tree行之后,在include7ѭ中仅包含
。 有关更多信息,这是我在Google快速搜索后创建的博客:http://www.rubyinside.com/how-to-rails-3-1-coffeescript-howto-4695.html 至于IE 8的事情。 IE中的错误并非总是执行条件,因此请尝试
尝试重设解析器以执行规则有点骇人听闻
抚驰
我的应用程序/资产/样式表/application.css现在看起来像:
在app / views / layouts / application.html.erb中,我有:
希望这对某人有帮助。
喷乡顾沥沪
中,然后在您自己的
中将它们包括在
中,例如:
嘘崇蔡对
将常见的蓝图文件添加到清单中,以便将它们预编译到application.css中: /app/assets/stylesheets/application.css
添加application.css,其中将包含常见的蓝图文件。还要有条件地添加print.css和ie.css: /Views/layouts/application.html.erb
由于有条件,print.css和ie.css需要作为application.css之外的单独文件使用(默认情况下,它们不在require \'blueprint \'中)。因此,我们需要将它们添加到: /Configuration/envoirnments/production.rb
然后运行:
括宠
最后,更改布局中的链接标记(确保删除\“ application \”样式表)
然后,您可以手动添加任何其他样式表(例如特定于\“ ie \”)和其他样式表组(例如用于加载所有蓝图文件的蓝图...) 您可能还需要(在production.rb中)
甲车劲
蹄寄噬非芹