Skip to content

Fix grid for @media print #37537

@SPodjasek

Description

@SPodjasek

Prerequisites

Describe the issue

Previously (not sure how far ago), it was possible to use grid rows & columns on print media. However, as I've found in v5.2, they stopped working on printed media.

My hot fix is pretty simple, but I've no clue how to fit it correctly in the current source tree not to break other things, so I'm posting this as an issue, not a PR:

@media print {
  @each $breakpoint in map-keys($grid-breakpoints) {
    $infix: breakpoint-infix($breakpoint, $grid-breakpoints);

    @for $i from 1 through $grid-columns {
      .col#{$infix}-#{$i} {
        @include make-col($i, $grid-columns);
      }
    }
  }
}

Reduced test cases

Simple test with example from documentation (https://getbootstrap.com/docs/5.2/layout/grid/#stacked-to-horizontal): https://vvlanw--run.stackblitz.io/ - when rendered in browser columns are split as requested in a row, when you do a print preview all columns are 100% wide.

What operating system(s) are you seeing the problem on?

Linux

What browser(s) are you seeing the problem on?

Chrome

What version of Bootstrap are you using?

v5.2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions