Ruby rails应用程序中的引导仅适用于.scss
我目前正在学习Rails,并正在开发一个简单的社交媒体/博客应用程序。 我已经建立了一个基本视图,并且正在尝试将引导CSS应用于它 我按照以下步骤尝试将引导应用于我的应用程序: 1.)将gem“bootstrap sass”添加到gemfile中并运行“bundle install” 2.)在application.css中添加了“*=require bootstrap” 3.)将“/=require bootstrap”添加到application.js (四) 增加: 它将突出显示行“*=需要引导” 但是,当我将扩展名更改为application.css.scss并添加如下@import语句时,它与应用的引导一起工作 application.css.scss:Ruby rails应用程序中的引导仅适用于.scss,ruby,ruby-on-rails-3,bootstrap-4,Ruby,Ruby On Rails 3,Bootstrap 4,我目前正在学习Rails,并正在开发一个简单的社交媒体/博客应用程序。 我已经建立了一个基本视图,并且正在尝试将引导CSS应用于它 我按照以下步骤尝试将引导应用于我的应用程序: 1.)将gem“bootstrap sass”添加到gemfile中并运行“bundle install” 2.)在application.css中添加了“*=require bootstrap” 3.)将“/=require bootstrap”添加到application.js (四) 增加: 它将突出显示行“*=需
* 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, 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 other CSS/SCSS
* files in this directory. Styles in this file should be added after
the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_tree .
*= require bootstrap
*= require_self
*/
@import "bootstrap";
所以有两个问题…1.)为什么我的应用程序需要.scss和@import才能启动 2.)为什么我的“=require bootstrap”必须是“=require\u bootstrap”
谢谢 Bootstrap-sass是Bootstrap-CSS的sass实现,它最初是用更少的语言编写的 如果您想要更少的css,可以从getbootstrap.com获得 如果您希望继续使用
引导sass
:
- 您需要将
重命名为应用程序.css
应用程序.scss
- 删除
*=需要引导
- 添加我在下面指出的行 从导入开始
- 此外,您还需要包括
引导链轮
application.scss
文件的外观:
...
*
*= require_self
*/
@import "bootstrap-sprockets";
@import "bootstrap";
...
Myapplication.js
...
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
...
//= require bootstrap-sprockets
...
请在标题为Integrating Bootstrap with Rails的部分中签出此参考。application.css.scss:
*= require bootstrap #remove it
*= require_self
*= require_tree .
*/
application.js
//= require bootstrap-sprockets
//= require jquery
最重要的是打开一个新的scss文件并添加:
@import "bootstrap-sprockets";
@import "bootstrap";
打开一个名为什么的新.scss?我不明白为什么需要这样做。我已经在application.cscc.scss中@import“bootstrap”了。不要在application.css.scss中添加
@import“bootstrap”
,新的scss文件可以根据需要命名
//= require bootstrap-sprockets
//= require jquery
@import "bootstrap-sprockets";
@import "bootstrap";