简体   繁体   English

如何在一个Rails应用程序中使用两个CSS框架? (在同一应用程序上使用基金会和波旁威士忌整洁)

[英]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.

相关问题 在同一个Rails应用程序中使用两个单独的CSS框架 - Using two separate CSS frameworks in same Rails app 如何在我的Rails 4应用程序中配置Compass和Zurb Foundation 5,以便它们都可以在同一目录中访问? - How can I configure Compass and Zurb Foundation 5 in my Rails 4 app so that they are both accessible in the same directory? 如何使用devise的“ warden”对与使用devise的rails应用程序位于同一堆栈中的机架应用程序进行身份验证? - How can I use devise's “warden” to authenticate a rack app in the same stack as the rails app that uses devise? 我的Rails 4.2.6应用程序使用两个数据库。 我可以只使用一个用于测试目的吗? - My Rails 4.2.6 app uses two databases. Can I only use one for testing purposes? Rails 4 scss中的波旁威士忌/纯宝石错误 - Error with bourbon/neat gems in rails 4 scss 我如何在Rails应用程序中使基础全局变量可用于我的所有scss文件 - How can i make foundation global variables available to all my scss files in a rails app 我可以在同一应用程序中使用CSS资产和公用文件夹吗? - Can I use CSS assets and the public folder in the same app? 安装Foundation后,如何更改Rails的默认CSS? - How can I change rails default css after installing Foundation? 如何将JQuery UI CSS添加到Rails应用程序 - How can I add the JQuery UI CSS to a Rails App Rails + Carrierwave + RS Cloudfiles,如何为一个应用程序使用多个容器? - Rails + Carrierwave + RS Cloudfiles, how can I use multiple containers for one app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM