css - 如何在 rails 中自定义 bulma 变量

标签 css ruby-on-rails bulma

我正在使用 bulma rails gem,我想自定义它使用的一些变量,特别是字体颜色。

根据 bulma 文档 http://bulma.io/documentation/overview/customize/我应该这样做:

// 1. Import the initial variables
@import "../sass/utilities/initial-variables"

// 2. Set your own initial variables
// Update blue
$blue: #72d0eb
// Add pink and its invert
$pink: #ffb3b3
$pink-invert: #fff
// Add a serif family
$family-serif: "Merriweather", "Georgia", serif

// 3. Set the derived variables
// Use the new pink as the primary color
$primary: $pink
$primary-invert: $pink-invert
// Use the existing orange as the danger color
$danger: $orange
// Use the new serif family
$family-primary: $family-serif

// 4. Import the rest of Bulma
@import "../bulma"

但是我不确定如何使用我正在使用的 rails gem 来实现它。

目前我的 application.css 文件是这样的:

/*
 * 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 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_self
 */

@import "bulma";

效果很好。但是,如果我将其更改为类似于 bulma 文档中的示例,即使将 @import "../bulma" 更改为 @import "bulma" 并且@import "../sass/utilities/initial-variables" @import "sass/utilities/initial-variables"

我想这里的问题是第一次导入变量,但我不知道如何导入它。这是 gem 中的文件:https://github.com/joshuajansen/bulma-rails/blob/master/app/assets/stylesheets/sass/utilities/variables.sass

谢谢!

最佳答案

好的,成功了。

我在 app/assets/stylesheets 目录中创建了一个名为 application.css.scss 的文件并添加了以下内容:

$blue: #72d0eb;
$pink: #ffb3b3;
$pink-invert: #fff;
$family-serif: "Merriweather", "Georgia", serif;
$primary: $pink;
$primary-invert: $pink-invert;
$family-primary: $family-serif;

@import "bulma";

这很好用。添加初始 import 语句会导致失败,尝试使用它尝试使路径正确,但对我来说总是失败。不确定这是否有任何我没有看到的意义,但无论如何现在对我有用。

关于css - 如何在 rails 中自定义 bulma 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44347593/

相关文章:

css - rails 上的样式下拉 ruby

javascript - Bootstrap 4 更改特定元素的工具提示颜色

javascript - html.erb 模板中的 v-model 呈现 function () { [native code] }

ruby-on-rails - Rails - 给定文本 block ,自动链接

nuxt.js - 如何与 Bulma 一起使用 Nuxt 颜色模式?

HTML/CSS 元素位置

css - 如何在 html 中为高分辨率屏幕设置媒体查询

ruby-on-rails - 如何连接 Rails 中的 SQL Server 和适用于 Linux 的 Microsoft ODBC 驱动程序?

css - 仅当在无样式的 HTML Details 标签内时,表单元素样式不正确

html - Bulma - 如何将图像和文本内联