【问题标题】:Can't get twitter-bootstrap-rails mixin to work无法让 twitter-bootstrap-rails mixin 工作
【发布时间】:2018-12-04 15:23:24
【问题描述】:

我在app/assets/stylesheets/scaffolds.scss 中有以下CSS:

.input-container {
    @include make-lg-column(3);
}

当我加载页面时,我收到以下错误:

未定义的 mixin 'make-lg-column'。

app/assets/stylesheets/bootstrap_and_overrides.css.less 中有以下几行:

@import "twitter/bootstrap/variables.less";
@import "twitter/bootstrap/mixins.less";

这就是我在app/assets/stylesheets/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, 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 bootstrap_and_overrides
 *= require_tree .
 *= require_self
 */

如有任何关于如何解决此问题的建议,我们将不胜感激。

【问题讨论】:

    标签: ruby-on-rails twitter-bootstrap twitter-bootstrap-rails


    【解决方案1】:

    您似乎在SCSS 文件中使用带有LESS 的引导程序。我建议尝试SASS 版本。

    # Gemfile
    gem 'bootstrap-sass', '~> 3.3.7'
    gem 'sass-rails', '>= 3.2'
    
    # SCSS file
    @import "bootstrap-sprockets";
    @import "bootstrap";
    

    【讨论】:

    • 我会接受这一点,因为它说明了我的问题的根源——我对 Less 和 Sass 感到困惑——尽管我的解决方案不是切换到 Sass,而是创建一个新的 .less 文件并在那里应用mixin。
    • 那么您应该将app/assets/stylesheets/scaffolds.scss 转换为less 或使用LESS 创建另一个样式表文件并在那里使用LESS mixins。
    猜你喜欢
    • 2013-09-10
    • 2019-05-14
    • 1970-01-01
    • 1970-01-01
    • 2017-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多