twitter-bootstrap 如何在 Rails 4 中使用 Bootstrap 3 RC
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18032307/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to use Bootstrap 3 RC with Rails 4
提问by pastullo
I'm trying to migrate from Bootstrap 2, to version 3 RC1 in a Rails 4 project.
我正在尝试从 Bootstrap 2 迁移到 Rails 4 项目中的版本 3 RC1。
Initially I used bootstrap-sass gem 2.3.2 and everything worked smoothly.
最初我使用 bootstrap-sass gem 2.3.2 并且一切顺利。
How can i add Boostrap 3 to my project now? I can't find any gem already converted to SASS and the official documentation tells to compile it into CSS from LESS.
我现在如何将 Boostrap 3 添加到我的项目中?我找不到任何已经转换为 SASS 的 gem,官方文档告诉将它从 LESS 编译成 CSS。
I'm fairly new to all of this so i'm really getting confused here, any help?
我对这一切都很陌生,所以我真的很困惑,有什么帮助吗?
UPDATESeems like the gem i was using in the first place has been finally updated: https://github.com/twbs/bootstrap-sass
更新似乎我最初使用的 gem 终于更新了:https: //github.com/twbs/bootstrap-sass
回答by ShenoudaB
try using https://github.com/anjlab/bootstrap-rails
尝试使用https://github.com/anjlab/bootstrap-rails
by adding the following to your Gemfile:
通过将以下内容添加到您的Gemfile:
gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails',
:github => 'anjlab/bootstrap-rails',
:branch => '3.0.0'
In your application.jsadd the following:
在您的application.js 中添加以下内容:
//= require twitter/bootstrap
In your application.cssadd the following before anything else:
在您的application.css 中,在其他任何内容之前添加以下内容:
*= require twitter/bootstrap
回答by TSr
There is already release candidate that you can use, add to GemFile:
已经有你可以使用的候选版本,添加到 GemFile:
gem 'bootstrap-sass', github: 'thomas-mcdonald/bootstrap-sass'
Additionally if you upgrade from bootstrap 2 then you have to remove previous gem before.
此外,如果您从 bootstrap 2 升级,那么您必须先删除以前的 gem。
回答by Andrew Patzer
I tried the solution suggested by ShenoudaB and got it to work just fine. Things I needed to change from the previous version were:
我尝试了 ShenoudaB 建议的解决方案并让它正常工作。我需要从以前的版本改变的事情是:
- In your application.css.scss file, make sure you are referencing twitter/bootstrap instead of just bootstrap.
- I also needed to add an @import "twitter/bootstrap"; line to my css. This may be redundant with the above tip, but once I added it, it worked fine.
- In your application.js file, you should reference twitter/bootstrap in your //=require statement.
- 在您的 application.css.scss 文件中,确保您引用的是 twitter/bootstrap 而不是 bootstrap。
- 我还需要添加一个@import“twitter/bootstrap”;线到我的CSS。对于上述提示,这可能是多余的,但是一旦我添加了它,它就可以正常工作。
- 在 application.js 文件中,您应该在 //=require 语句中引用 twitter/bootstrap。
I also noticed that some of the styles changed. Check the new documentation and make sure your class names match the new ones.
我还注意到一些样式发生了变化。检查新文档并确保您的类名与新的匹配。
That's all I did and it worked for me. Good luck getting your app to work!
这就是我所做的一切,它对我有用。祝您的应用程序运行顺利!
回答by Siddhartha Mukherjee
Why not the official one
为什么不是官方的
Thanks
谢谢
回答by zabumba
Since you are already using bootstrap-sass gem
由于您已经在使用 bootstrap-sass gem
I'd recommend this
我会推荐这个
回答by wael
Ther is a twitter bootsrap 3 gem : https://github.com/yabawock/bootstrap-sass-rails
有一个 twitter bootsrap 3 gem:https: //github.com/yabawock/bootstrap-sass-rails
回答by valk
And somehow nobody mentioned http://alademann.github.io/sass-bootstrap/and I wonder why.
不知何故,没有人提到http://alademann.github.io/sass-bootstrap/,我想知道为什么。

