使用 Rails 自定义 Zurb Foundation 时遇到问题
Trouble customizing Zurb Foundation with Rails
说到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 %>
我确定我忽略了一些简单的事情。但是我找不到任何 "for dummies" 示例来说明该怎么做。请帮忙。
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";
我的工作方式是将以下行添加到 app/assets/stylesheets/application.scss
,并添加此行:
@import "foundation_and_overrides";
您还可以从同一文件中删除任何 *= require foundation
,因为 foundation_and_overrides 已经导入了所需的文件。
我不确定这是最好的方法,但它适用于 Foundation 5(我还没有尝试过 Foundation 6)。
说到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 %>
我确定我忽略了一些简单的事情。但是我找不到任何 "for dummies" 示例来说明该怎么做。请帮忙。
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";
我的工作方式是将以下行添加到 app/assets/stylesheets/application.scss
,并添加此行:
@import "foundation_and_overrides";
您还可以从同一文件中删除任何 *= require foundation
,因为 foundation_and_overrides 已经导入了所需的文件。
我不确定这是最好的方法,但它适用于 Foundation 5(我还没有尝试过 Foundation 6)。