首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何配置bootstrap-sass on rails

如何配置bootstrap-sass on rails
EN

Stack Overflow用户
提问于 2015-01-22 19:33:28
回答 2查看 94关注 0票数 0

我正在构建一个Rails应用程序,我决定使用bootstrap和sass。

我遵循github页面上的指南:

代码语言:javascript
复制
https://github.com/twbs/bootstrap-sass

所以,现在我安装了gem ('bootstrap-sass','sass-rails'),我的application.css (现在的application.sass)如下所示:

代码语言:javascript
复制
1 @import "bootstrap-sprockets";
2 @import "bootstrap";

我的application.js文件如下所示:

代码语言:javascript
复制
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 .

然后这个指南差不多就结束了。问题是我的应用程序中没有bootstrap (通过查看源代码,我无法在页面的任何位置看到它),并且我不知道如何使用sass。我接下来该怎么办?我错过了什么吗?

EN

回答 2

Stack Overflow用户

发布于 2015-01-22 19:56:47

听起来这一切都应该准备好了,但你必须开始编写一些可以应用的代码。也许可以用这个来测试它。在application.html.erb文件的body下放置以下内容:

代码语言:javascript
复制
<div id="container">
    <div class="main">
            <h1>Main Content</h1>
    </div>

然后在css文件中尝试如下所示

代码语言:javascript
复制
#container {
    .main {
            width:600px;
            h1 {
                    color: $red;
            }
    }

确保在安装包之后重新启动了服务器。引导程序变量列表可以在http://getbootstrap.com/customize/#less-variables中找到

票数 0
EN

Stack Overflow用户

发布于 2015-01-22 22:07:46

我发现了错误:我将所有的import标签写在html

代码语言:javascript
复制
<title>

标记而不是

代码语言:javascript
复制
<head> 

标签。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28087758

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档