Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Issues
  • #2796
Closed
Open
Issue created Mar 26, 2012 by Administrator@rootContributor

Include responsive styles based on LESS variable

Created by: richardp-au

It makes sense to include the responsive CSS in the same file as the other CSS (one HTTP request instead of two). However, it's also a good idea to make it easy for people to include or exclude the responsive styles (and indeed this is why Bootstrap separates them into two files).

I'd suggest using a LESS variable to control the inclusion of the responsive styles in the output CSS. This can be done using pattern-matching in LESS.

In variables.less, add:

@responsive: true; // or anything else (e.g.: false) to disable

In bootstrap.less add:

// Responsive styles
.responsive(@_) {
}
.responsive(true) {
  @import "responsive.less";
}
.responsive(@responsive);

Now, simply by changing the @responsive variable, you can control the inclusion of responsive.less.

LESS will match the .responsive(@responsive) statement to either of the .responsive(...) mixins depending on the value of the first parameter. The .responsive(true) mixin is only matched when the @responsive variable is true. The .responsive(@_) mixin is matched all the time and this is required to prevent the LESS compiler throwing an error because it couldn't find a matching mixin for non-true values in @responsive.

Assignee
Assign to
Time tracking