2017-01-09 63 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