2014-02-08 5 views
1

내 레일 (4.0.0) 프로젝트에서 bootstrap-sass (3.1.0.2) 및 sass-rails (4.0.1)를 사용하려고합니다.Rails가있는 부트 스트랩 Sass 4

내 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 파일이 스타일 시트 폴더에 있으며 다음과 같습니다

@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> 

서버를 시작하고 페이지를 방문하면 부트 스트랩 스타일링없이 일반 텍스트로 표시됩니다.

어떻게해야 할 지에 대한 아이디어는 인정 될 것입니다. 여기에있는 몇몇 사람들이 보석을 사용하지 않는 것 같습니다. 이 접근 방식에 대한 이유가 있습니까? 매우 감사합니다!

# 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를) 가져 오기 :

+0

HTML 페이지의 출처를 게시 할 수 있습니까? 몇 가지 정보가있을 수 있습니다. 가능하면 레이아웃 파일 – Muntasim

+0

'bundle '을 실행 했습니까? –

+0

application.css.scss에서 필요한 부트 스트랩을 시도 했습니까? 또는, conflig/application.rb 내부에 요구 사항을 추가해보십시오. (두 번째 방법으로 작업했는데 첫 번째 오류는 반환했습니다.) –

답변

0

여기 https://github.com/twbs/bootstrap-sass 내 설정이다.

+0

안녕하세요 빅터, 공유해 주셔서 감사합니다. 나는 css 행위의 순서가 중요한지 궁금해. 스타일 시트 폴더에있는 별도의 파일에 가져 오기 부트 스트랩이 있습니다.이 파일은 트리에서 가져옵니다. 나는 당신의 셋업을 시도해보고 그걸 가지고 행운을 얻지는 못하지만 새로운 프로젝트를 만들려고합니다. 어딘가에 다른 버그가있어서 작동하지 않을 수도 있습니다. 답장을 보내 주셔서 대단히 감사합니다. – Mel

+0

예, CSS 가져 오기 순서가 중요합니다. 제 경우'class.css.scss'에'body {background : white}'가 있고 제 events.css.scss에'body {background : red}'가 있으면'body' 배경 '는 이전 CSS를 무시하기 때문에'red'가됩니다. https://github.com/twbs/bootstrap-sass – Victor

+0

감사합니다. – Mel

5

며칠 전 거의 같은 문제에 직면했습니다. 내 구성은 꽤 비슷했지만 Bootstrap의 스타일 효과는 거의 작동하지 않았습니다 (특히 bg-whatever-color). 몇 가지 보석 업데이트 후 문제가 사라집니다. 아이디어

*= 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"; 

희망을 당신에게 내 application.scss의

bundle update 

부 :

내가

업데이트 나의 보석의 일부
gem 'rails', '4.0.3' 
gem "bootstrap-sass", "~> 3.1.1.0" 
gem 'font-awesome-sass' 
gem 'sass-rails', '~> 4.0.0' 

가 잊지 마세요

도움이됩니다!

관련 문제