如何在一个Rails应用程序中使用两个CSS框架? (在同一应用程序上使用基金会和波旁威士忌整洁) [英] How can I use two css frameworks in one rails app? (Using foundation and bourbon neat on same app)
问题描述
我有一个使用Foundation 3构建的Rails应用程序(不使用gem.它位于vendor/assets/stylesheets/foundation.min.css中).
I have a rails app that was built using foundation 3 (not using the gem. It is located in vendor/assets/stylesheets/foundation.min.css).
我想逐渐将样式代码转换为Bourbon/Neat.
And I want to gradually convert my styling code to Bourbon/Neat.
我要记住的一件事是在不完成重新编码的情况下不要破坏以前的布局.
One thing I have to have in mind is not to break the previous layouts while I'm not done with the recoding.
有可能这样做吗?
导轨版本:3.2.13 红宝石:1.9.3
rails version: 3.2.13 ruby: 1.9.3
推荐答案
对于应用中的任何给定页面,您都可以通过在该页面上包含样式表来包含所需的任何样式.
For any given page in your app, you can include whatever styling you want by including the stylesheets on that page.
因此,对于具有Foundation样式的页面,请确保您具有该样式表的链接,对于具有Bourbon/Neat样式的页面,请具有该样式表的链接.
So for pages that have Foundation styling, make sure you have a link to that stylesheet, and for pages have Bourbon/Neat styling, have a link to that stylesheet.
通常,您可以通过添加以下内容来查看布局文件中一起包含的所有样式表:
You typically see all the stylesheets included together in the layout file, by adding something like:
<%= stylesheet_link_tag "application", media: "all" %>
这只是指向索引文件(assets/stylesheets/application.css
),该索引文件又列出了应包含在页面上的所有其他样式表.
This simply points to an index file (assets/stylesheets/application.css
), which in turn lists all the other stylesheets that should be included on the page.
如果需要,可以将样式表一个接一个地添加到页面中,也可以使用2种不同的布局:1用于Foundation,1用于Bourbon/Neat.然后,在每个布局中都有不同的样式表集:
If you want, you could either include the stylesheets into your pages one-by-one, or you could use 2 different layouts: 1 for Foundation and 1 for Bourbon/Neat. Then within each of those layouts have different stylesheet sets:
# points to assets/stylesheets/foundation.css
<%= stylesheet_link_tag "foundation", media: "all" %>
# points to assets/stylesheets/bourbon.css
<%= stylesheet_link_tag "bourbon", media: "all" %>
然后,当您从一个过渡到另一个时,您可以一次更改一个控制器动作,以使用通过Bourbon/Neat布局设置的Bourbon/Neat样式表.
Then as you transition from one to the other, you can just change the controller actions one at a time to use the Bourbon/Neat stylesheet set by using the Bourbon/Neat layout.
这篇关于如何在一个Rails应用程序中使用两个CSS框架? (在同一应用程序上使用基金会和波旁威士忌整洁)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!