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
  • Merge requests
  • !29073

v4/v5: Row columns for responsive card decks and more

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Mark Otto requested to merge row-cols into master Jul 17, 2019
  • Overview 0
  • Commits 8
  • Pipelines 0
  • Changes 5

Overview

Trying to find a new way to do responsive card decks while not locking ourselves into more card classes. My thinking here is we can easily control the column (.col) width by the parent with responsive .row-cols-* classes, but I don't know how many we need (have 0-5 now).

<!-- Three columns at the medium breakpoint and up -->
<div class="row row-cols-md-3">
  <div class="col">Column</div>
  <div class="col">Column</div>
  <div class="col">Column</div> <!-- Wraps to new line here -->
  <div class="col">Column</div>
  <div class="col">Column</div>
</div>

/cc @twbs/css-review

How it works

We can add a default number of columns to support (thinking a max of 6). You can override this if you like, but otherwise we'll loop over it and generate the responsive classes.

Here's a simplified example with out the responsive infixes. See it in action via Sassmeister.

$row-columns: 6 !default;

@for $i from 1 through $row-columns {
  .row-cols-#{$i} > [class^="col"] {
    flex: 0 0 calc(100% / #{$i});
  }
}

Screenshots

Some screenshots to show how it's shaping up for grid columns and cards.

Screen Shot 2019-07-17 at 4 26 12 PM Screen Shot 2019-07-17 at 4 26 15 PM

Preview: https://deploy-preview-29073--twbs-bootstrap.netlify.com/docs/4.3/components/card/#grid-cards

https://deploy-preview-29073--twbs-bootstrap.netlify.com/docs/4.3/layout/grid/#row-columns

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: row-cols