简体   繁体   English

使用Less-Mixins和twitter-bootstrap-rails

[英]Using Less Mixins with twitter-bootstrap-rails

I'm making my first attempt to use bootstrap mixins with the twitter-bootstrap-rails gem with bootstrap. 我正在尝试使用bootstrap mixins和twitter-bootstrap-rails gem以及bootstrap。 Within the file app/assets/stylesheets/custom.less I have the following app/assets/stylesheets/custom.less我有以下内容

.form-left{
  .col-md-4;
  .col-md-offset-2;
}

So my aim is for the class form-left to behave as though it's styled with the bootstrap classes col-md-4 and .col-md-offset-2 . 所以我的目标是让类form-left的行为好像它是用引导类col-md-4.col-md-offset-2

The problem is that when I fire up the page, I am confronted with the following error: 问题是,当我启动页面时,我遇到以下错误:

.col-md-offset-2 is undefined (in app/assets/stylesheets/custom.less) .col-md-offset-2未定义(在app / assets / stylesheets / custom.less中)

What might I be leaving out? 我可能会遗漏什么? It's quite possible that it's somehting simple as I'm rather new at this. 它很可能很简单,因为我对此很新。

Many thanks for any guidance! 非常感谢任何指导!

Make sure the proper mixins and variables are loaded first: 确保首先加载正确的mixins和变量:

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

For using columns as mixins, the syntax is different. 对于使用列作为mixins,语法是不同的。 In your specific case, try it like this: 在您的具体情况下,请尝试这样:

.make-md-column(4) .make-md-column-offset(2) .make-md-column(4) .make-md-column-offset(2)

Take a look at here for the full documentation: http://getbootstrap.com/css/#grid-less 请查看完整文档: http//getbootstrap.com/css/#grid-less

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

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