Bootstrap CSS加载用bootstrap-sass,其他CSS将不加载 [英] Bootstrap CSS loading with bootstrap-sass, other CSS won't load

查看:160
本文介绍了Bootstrap CSS加载用bootstrap-sass,其他CSS将不加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Bootstrap作为我的Rails应用程序与bootstrap-sass v。3.1.1,它一直在我的application.css.scss文件中的以下工作:

  @importbootstrap; 

今天我试图添加一些自己的CSS一些添加的样式,我不能与Bootstrap。这是我的欢迎视图/控制器,所以我只是添加到welcome.css.scss

  .complete-class {
text-decoration:line-through;
}

阅读 Rails指南的这一部分,我的理解是,您可以在清单中包含一个像welcome.css.scss这样的CSS文件,像这样:

  @importbootstrap; 

/ *
* = require_self
* = require_tree。
* /

这没有成功应用我的CSS;也没有welcome.css.scss出现在head标签。



当我试图调试这我遇到了一些奇怪的事情,我觉得我应该指出: / p>

1。导入引导程序出错



VIM的Syntastic插件有效地指出了一个错误:

 要导入的文件未找到或无法读取:bootstrap。加载路径:/ home / stephen / code / blocitoff / app / assets / stylesheets 




  • a)此错误之前未显示,尽管我没有更改它引用的代码行@importbootstrap)






    <


2 。卸载引导程序



我搜索了上述错误,并找到这个问题,建议我卸载并重新安装bootstrap-sass。虽然好奇地,即使我卸载了这个gem,bootstrap styilng仍然保留在页面上。但是这没有用。



rails的版本是4.1.5


  1. 将所有css移至application.css.scss

由于似乎bootstrap正在从application.css.scss加载我不知怎的我添加了我的CSS,但是没有工作。


  1. 浏览器上的隐身模式

最后,我认为如果引导不会当我卸载bootstrap-sass然后也许他们正在我的浏览器缓存?我认为这并没有发生在开发,但只是为了防止我在隐身模式下启动铬。仍然没有变化。



除了解决这个问题,我真的很想了解这里发生了什么 - 希望我可以更好地了解如何

pre








< gem'bootstrap-sass','〜> 3.2.0'
gem'sass-rails','> = 3.2'

application.css

  / * 
* = require shared / bootstrap-base
* = require_self
* /

app / assets / stylesheets / shared / bootstrap-base.scss

  @importbootstrap; 


I'm using Bootstrap for my Rails application with bootstrap-sass v. 3.1.1, which has been working just fine with the following in my application.css.scss file:

@import "bootstrap";

and nothing else. Just today I tried adding some of of own CSS for some added styling that I don't get with Bootstrap. It's for my welcome view/controller so I just added it to welcome.css.scss

.complete-class {
  text-decoration: line-through;
}

From reading this section of the Rails Guides my understanding was that you could include a CSS file like welcome.css.scss in the manifest like this:

@import "bootstrap";

/*
*= require_self
*= require_tree .
*/

This did not successfully apply my CSS; nor did welcome.css.scss appear in the head tag.

As I tried to debug this I encountered a few weird things that I feel I should also point out:

1. Error importing bootstrap

The Syntastic plugin for VIM helpfully pointed out an error:

File to import not found or unreadable: bootstrap. Load path: /home/stephen/code/blocitoff/app/assets/stylesheets

This is strange because

  • a) This error wasn't showing up before, despite the fact that I didn't change the line of code it refers to (@import "bootstrap")

and

  • b) bootstrap is still applied faithfully in my page layout and appears in the assets in the head tag.

2. Uninstalling bootstrap-sass

I searched for the above error and found this issue which suggested that I uninstall and reinstall bootstrap-sass. That didn't work although curiously the bootstrap styilng remained on the page even when I had uninstalled the gem.

The version of rails is 4.1.5

  1. Moving all the css to application.css.scss

Since it seems that bootstrap is being loaded from the application.css.scss somehow I added my css there but that didn't work either.

  1. Incognito mode on the browser

Finally I thought that if the bootstrap isn't going away when I uninstall bootstrap-sass then maybe they're being cached on my browser? I thought that didn't happen in development but just in case I fired up chrome in incognito mode. Still no change.

Beyond just figuring out how to solve this I'd really like to understand just what's going on here--hopefully I can get a better idea of how the rails asset pipeline works.

解决方案

Gemfile

gem 'bootstrap-sass', '~> 3.2.0'
gem 'sass-rails', '>= 3.2'

application.css

/*
*= require shared/bootstrap-base
*= require_self
*/

app/assets/stylesheets/shared/bootstrap-base.scss

@import "bootstrap";

这篇关于Bootstrap CSS加载用bootstrap-sass,其他CSS将不加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆