[英]How to configure bootstrap-sass on rails
我正在構建一個Rails應用程序,因此決定使用bootstrap和sass。
我遵循github頁面上的指南:
https://github.com/twbs/bootstrap-sass
所以,現在我安裝了我的gem('bootstrap-sass','sass-rails'),我的application.css(現在為application.sass)如下所示:
1 @import "bootstrap-sprockets";
2 @import "bootstrap";
我的application.js文件如下所示:
1 // This is a manifest file that'll be compiled into application.js, which will include all the files
2 // listed below.
3 //
4 // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6 //
7 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 // compiled file.
9 //
10 // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11 // about supported directives.
12 //
13 //= require jquery
14 //= require jquery_ujs
15 //= require turbolinks
16 //= require bootstrap-sprockets
17 //= require_tree .
然后指南幾乎結束了。 問題是我的應用程序中沒有引導程序(通過查看源代碼無法在頁面的任何位置看到它),而且我不知道如何使用sass。 接下來我該怎么辦? 我錯過了什么?
聽起來應該已經准備就緒,但是您必須開始編寫一些可以應用的代碼。 也許對此進行測試。 在body下的application.html.erb文件中,放入以下內容:
<div id="container">
<div class="main">
<h1>Main Content</h1>
</div>
然后在css文件中嘗試這個
#container {
.main {
width:600px;
h1 {
color: $red;
}
}
確保在安裝捆綁軟件后重新啟動服務器。 引導程序變量列表可以在以下位置找到: http://getbootstrap.com/customize/#less-variables
我發現了錯誤:我在html之間寫了所有import標簽
<title>
標簽而不是
<head>
標簽。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.