Repository navigation
Docs: restore the gutters in the Masonry example - #43449
Open
vladosskins178 wants to merge 1 commit into
Open
vladosskins178 wants to merge 1 commit into
vladosskins178 wants to merge 1 commit into
Conversation
Since the grid uses native gap gutters (twbs#43282), Masonry's absolute positioning ignores the row gap, so the cards touched and the last column ended two gutters short of the row. Give Masonry a gutter sizer as wide as --bs-gutter-x and limit its items to the row's columns.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The Masonry example lost its horizontal gutters after the switch to native
gapgutters (#43282). Masonry positions the columns absolutely, so the row'sgapdoes not apply to them. It places each column one column width after the previous one, so the cards touch. The last column also ends two gutters short of the row (48px at 1400px wide).This gives Masonry a gutter sizer: an empty
.masonry-gutterelement withstyle="width: var(--bs-gutter-x)", passed as Masonry'sgutteroption, withitemSelectorlimited to the other children of the row. The column widths already account for the gap ((100% + gap) * n - gap), so column width plus gutter matches the grid exactly. The intro paragraph shows the new options and explains why the sizer is needed.Motivation & Context
Fixes #43448.
I tested it in headless Chrome. I compiled
scss/bootstrap.scssfrommainand ran the build's PostCSS config to get the--bs-prefix. Then I rendered the example's markup with Masonry 4.2.2 (the same CDN file and SRI hash) and measured the card positions:Resizing a loaded page (1400 → 900 → 500 → 1200) re-lays the cards out with the same 24px gutters. A note on the selector: Masonry's
itemSelectoralso matches descendants of the children. A plain:not(.masonry-gutter)would turn every element inside the cards into an item, so it is scoped with.row >.Type of changes
Checklist
npm run lint) (markup-only change in one example; inline styles are allowed by the html-validate config)Live previews
Related issues
#43448, #43282