[英]How can I use two css frameworks in one rails app? (Using foundation and bourbon neat on same app)
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). 我有一个使用Foundation 3构建的Rails应用程序(不使用gem。它位于vendor / assets / stylesheets / foundation.min.css中)。
And I want to gradually convert my styling code to Bourbon/Neat. 我想逐渐将样式代码转换为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. 我要记住的一件事是不要破坏以前的布局,而不必完成重新编码。
Is it possible to do this? 是否有可能做到这一点?
rails version: 3.2.13 ruby: 1.9.3 rails版本: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. 对于应用程序中的任何给定页面,您都可以通过在该页面上包含样式表来包含所需的任何样式。
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. 因此,对于具有Foundation样式的页面,请确保您具有该样式表的链接,对于具有Bourbon / Neat样式的页面,请具有该样式表的链接。
You typically see all the stylesheets included together in the layout file, by adding something like: 通常,您可以通过添加以下内容来查看布局文件中一起包含的所有样式表:
<%= stylesheet_link_tag "application", media: "all" %>
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. 这只是指向索引文件(
assets/stylesheets/application.css
),该索引文件又列出了应该包含在页面上的所有其他样式表。
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. 如果需要,可以将样式表一个接一个地添加到页面中,也可以使用2种不同的布局:1用于Foundation,1用于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" %>
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. 然后,当您从一个过渡到另一个时,您可以一次更改一个控制器动作,以使用通过Bourbon / Neat布局设置的Bourbon / Neat样式表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.