简体   繁体   English

如何在rails4中使用sass?

[英]How to use sass in rails4?

i have installed sass by using我已经通过使用安装了 sass

in my Gemfile在我的 Gemfile 中

gem 'sass-rails', '~> 5.0'

and run并运行

bundle install

i am sure that sass was installed我确定安装了 sass

but how to import it into html.erb???但是如何将它导入到 html.erb 中???

SASS is a CSS-Engine SASS 是一个 CSS 引擎

HAML is a HTML-Engine HAML 是一个 HTML 引擎


using sass-rails is setting up your assets pipeline to also use .sass or .scss files instead of regular css files.使用sass-rails正在建立自己的资产管道也使用.sass.scss文件,而不是常规的css文件。

exmaple for sass is sass 的例子是

a
 color: #fff
 margin: 10px
 &:hover
   color: red

inside of your application.css then you just require all those files you need to have ie //=require my_styles.sass在你的application.css你只需要所有你需要的文件,即//=require my_styles.sass

haml is the template engine which allows you to use haml files. haml是允许您使用 haml 文件的模板引擎。 gem 'haml-rails is enabling it. gem 'haml-rails正在启用它。

then you can use templates like然后你可以使用模板

.wrapper
  %h1 My HAML Headline
  %h2= @page_title

  .col-md-12.strong
    %span GTFO :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM