2017-01-09 36 views
0

或者他们是?当我在任何引导组件上使用inspect元素时,它将从application.css(不是bootstrap本身)获取CSS。我很确定我在安装时做了错误的事情,尽管我经历了几次指导。Bootstrap v4在Rails中安装问题

忘记我用Rails 4.2.6和使用宝石从补充: https://github.com/twbs/bootstrap-rubygem#a-ruby-on-rails

这是我的意思,例如BTN类工作,但他们并不指向来引导在检查元素而是应用于application.css。此外,导航栏(从getbootstrap.com复制粘贴)的作品尽可能的JavaScript下拉走,但CSS关闭。 enter image description here

的Gemfile

#Bootstrap V4 Alpha 
gem 'bootstrap', '~> 4.0.0.alpha6' 
* sprockets-rails (3.2.0) 

application.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 any plugin's vendor/assets/stylesheets directory 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 bottom of the 
* compiled file so the styles you add here take precedence over styles defined in any styles 
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new 
* file per style scope. 
* 
*/ 

@import "bootstrap"; 

的application.js

// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 
// about supported directives. 
// 
//= require jquery 
//= require jquery_ujs 
//= require turbolinks 
//= require_tree . 
//= require bootstrap 

回答

1

在你application.js文件的地方//= require bootstrap//= require jquery因此该文件将被看像这样:

// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 
// about supported directives. 
// 
//= require jquery 
//= require bootstrap 
//= require jquery_ujs 
//= require turbolinks 
//= require_tree . 

重新启动您的rails server并且更改将生效。

+0

感谢您的答复,我试过但没有改变。 – Dotol

0

仔细看看你的application.css文件的注释。

* This is a manifest file that'll be compiled into application.css, which will include all the files 
* listed below. 

这就是为什么它看起来好像所有的CSS是从application.css来了,但你在文件的底部导入引导CSS ..

+0

我移动了导入语句,但没有改变。 – Dotol

+0

尝试删除turbolinks – disc0ninja