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
  • #24273
Closed
Open
Issue created Oct 06, 2017 by Administrator@rootContributor

'no-gutters' implementation in Sass for grids

Created by: ihorzenich

We can use <div class="row no-gutters"> in html, but in case of implementing this in Sass we need to manually add zero-margin/padding:

For example:

// Grid with 'no-gutters' NOW

.example-row {  
  @include make-row(); // or just @extend .row;
  margin-left: 0;
  margin-right: 0;
}

.example-col-2 {
  @include make-col-ready(); // or just @extend .col-2;
  @include make-col(2);
  padding-left: 0;
  padding-right: 0;
}

.example-col-10 {
  @include make-col-ready();
  @include make-col(10);
  padding-left: 0;
  padding-right: 0;
}

Maybe it will be usefull to add an option for Sass mixins like:

@mixin make-row($gutters: 'gutters') {
  display: flex;
  flex-wrap: wrap;
  @if $gutters == 'gutters' {
    margin-right: ($grid-gutter-width / -2);
    margin-left:  ($grid-gutter-width / -2);
  }
}

@mixin make-col-ready($gutters: 'gutters') {
  position: relative;
  // Prevent columns from becoming too narrow when at smaller grid tiers by
  // always setting `width: 100%;`. This works because we use `flex` values
  // later on to override this initial width.
  width: 100%;
  min-height: 1px; // Prevent collapsing
  @if $gutters == 'gutters' {
    padding-right: ($grid-gutter-width / 2);
    padding-left:  ($grid-gutter-width / 2);
  }
}

So we could write:

// Grid with 'no-gutters' AFTER

.example-row {  
  @include make-row('no-gutters');
}

.example-col-2 {
  @include make-col-ready('no-gutters');
  @include make-col(2);
}

.example-col-10 {
  @include make-col-ready('no-gutters');
  @include make-col(10);
}
Assignee
Assign to
Time tracking