- From: Dmitry Statsenko via GitHub <sysbot+gh@w3.org>
- Date: Tue, 12 Nov 2024 13:00:37 +0000
- To: public-css-archive@w3.org
Use of `masonry`, regardless of syntax or naming, goes beyond a "Pinterest design." Its capabilities will remain relevant and in demand over the long term, for example:
Desktop:

Mobile:

A simple example with three blocks: text, button, and image.
On desktop the button is positioned above the bottom edge of the image, so using `grid` won’t work here. Two columns are needed: one for the text and button, and the other for the image.
On mobile the image is placed between the text and button, and there’s no simple way to move a block from one column to another.
One approach is to use `display: contents;` on the columns and reorder the elements, but this can make the CSS harder to read. Another option is to add two identical images in the HTML and show/hide them depending on screen size, though this isn’t an ideal solution either.
`masonry` makes this very easy.
New Masonry Layout:
```css
.masonry {
display: masonry;
masonry-template-tracks: 50% 1fr;
@media (width <= 992px) {
display: block;
}
}
```
Just Use Grid:
```css
.just-use-grid {
display: grid;
grid-template-rows: masonry;
grid-template-columns: 50% 1fr;
@media (width <= 992px) {
display: block;
}
}
```
--
GitHub Notification of comment by alkorlos
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11060#issuecomment-2470471615 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 12 November 2024 13:00:38 UTC