Rails 3: Access to twitter bootstrap variables + mixins without importing it

后端 未结 2 677
灰色年华
灰色年华 2021-02-15 15:12

I\'m using Rails 3 for the first time (especially asset pipelining and less-rails-bootstrap), so I might be missing some really basic concept here. I\'ve tried two approaches fo

2条回答
  •  既然无缘
    2021-02-15 15:59

    Your answer is sufficient if you want to exclusively use the default twitter bootstrap variables. If you find yourself wanting to override the variables and have them applied to BOTH twitter bootstrap's styles AND your own styles, you'll need to do separate out your variables into its own myvariables.less file and have that file included with twitter bootstrap instead of in the manifest.

    Example

    application.css:

    /*
     * Notice we aren't including twitter/bootstrap/bootstrap in here
     *= require bootstrap_and_overrides
     *= require mystyles
     */
    

    bootstrap_and_overrides.less:

    # Bootstrap with both bootstrap's variables, and your own
    @import "twitter/bootstrap/bootstrap";
    @import "myvariables";
    

    mystyles.less:

    # Your styles with both bootstrap's variables, and your own
    @import "myvariables";
    h1 {
      // Use 
      color: @textColor;
    }
    

    myvariables.less:

    @import "twitter/bootstrap/variables";
    @textColor: green;
    

提交回复
热议问题