1

我正在尝试在我的 rails (4.0.0) 项目中使用 bootstrap-sass (3.1.0.2) 和 sass-rails (4.0.1)。

我的 application.css.scss 文件如下所示:

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * 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 font-awesome
*= require_tree .
*/ 

我的 bootstrap_and_overrides.css.scss 文件位于 stylesheets 文件夹中,如下所示:

@import "bootstrap";

我设置了一个测试页面来试用它:

    <div class="container">
<h2>test terms</h2>
<h1>h1. Bootstrap heading <small>Secondary text</small></h1>
<p class="bg-primary">.dfd..</p>
<p class="bg-success">..sdfas.</p>
<p class="bg-info">..sdfs.</p>
<p class="bg-warning">.asdf..</p>
<p class="bg-danger">.adf..</p>
<p>test terms</p>


<button type="button" class="btn btn-primary">Default</button>

</div>
<button type="button" class="btn btn-info">Info</button>

当我启动服务器并访问页面时,它以纯文本呈现,没有引导样式。

任何关于做什么的想法将不胜感激。看来这里的一些人不使用宝石。这种方法有原因吗?非常感谢!

4

2 回答 2

5

I faced nearly the same problem few days ago. My configuration was quite the same but only few styling effects of Bootstrap were not working (especially the bg-whatever-color). After few gems updated the problem disappear.

Some of my gems that I updated

gem 'rails', '4.0.3'
gem "bootstrap-sass", "~> 3.1.1.0"
gem 'font-awesome-sass'
gem 'sass-rails', '~> 4.0.0'

Don't forget the:

bundle update

Part of my application.scss to give you an idea

*= require jquery.ui.all
*= require select2
*= require font-awesome
*/

@import "mixin_and_var";
// changing the breakpoint value before importing bootstrap style
// This change is made for the menu (navbar) to collapse on tablet for better view
$screen-sm:1024px;
@import "bootstrap";

@import "general_layout";
@import "header";
@import "footer";
@import "menus";
@import "pagination";
@import 'login';
@import "error";

Hope it helps!

于 2014-03-23T19:11:55.237 回答
0

这是我使用https://github.com/twbs/bootstrap-sass的设置:

# Gemfile
gem 'bootstrap-sass'

# application.css.scss
/*
 *= require_self
 *= require vendor
 * require_tree .
 */

@import "bootstrap";

// Import individual stylesheet
@import "base"; /* app/assets/stylesheets/base.css.scss */
@import "events"; /* app/assets/stylesheets/events.css.scss */

require_tree .被禁用,而是导入单个 CSS 文件 ( base, events)。

于 2014-02-08T08:52:49.090 回答