对于SCSS来说,我绝对是个新手。我需要一些帮助。
我在我的Rails 4.2.4项目中使用Zurb Foundation gem。我正在尝试进行一些全局自定义,例如更改body-bg颜色。我已进入assets / stylesheets文件夹中的foundation_and_overrides.scss并取消注释
$body-bg: $white;
希望将其改为$ steel或其他类似的东西。当我重新加载页面时,我得到了
app/views/layouts/application.html.erb where line #7 raised:
Undefined variable: "$white".
application.html.erb开始:
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><%= content_for?(:title) ? yield(:title) : "foodian" %></title>
<meta name="description" content="<%= content_for?(:description) ? yield(:description) : "Foodian" %>">
<%= stylesheet_link_tag "application" %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%# Modernizr is required for Zurb Foundation %>
<%= javascript_include_tag 'vendor/modernizr' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
我确信有一些简单的东西我会忽略。但我找不到任何&#34;傻瓜&#34;怎么做的例子。请帮忙。
application.css.scss
/*
* 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, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, 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 styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
/*= require foundation */
@import "foundation_and_overrides";
答案 0 :(得分:2)
我的工作方式是将以下行添加到app/assets/stylesheets/application.scss
,并添加以下行:
@import "foundation_and_overrides";
您还可以从同一个文件中删除任何*= require foundation
,因为foundation_and_overrides已经导入了所需的文件。
我不确定这是最好的方式,但它适用于基金会5(我还没有尝试过基金会6)。