Skip to content

Commit 543c989

Browse files
committed
[css-grid-3][masonry] Add explicit placement example
1 parent 89db07f commit 543c989

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

css-grid-3/Overview.bs

+46
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ Introduction</h2>
103103
<h3 id='background'>
104104
Background and Motivation</h3>
105105

106+
<h4 id='waterfall'>
107+
Waterfall Layout with Auto-placed Items</h4>
108+
106109
[=Masonry layout=], sometimes also called “waterfall layout”,
107110
is a common Web design pattern where a number of items--
108111
commonly images or short article summaries--
@@ -141,6 +144,49 @@ Background and Motivation</h3>
141144
unless you know up-front how tall each item will be,
142145
or use JavaScript for content measurement or placement.
143146

147+
Using a [=masonry container=] together with ''grid-area/auto''-positioned items
148+
yields this type of masonry layout.
149+
150+
<h4 id='collapse'>
151+
One-dimensional Grid Layout</h4>
152+
153+
[=Grid layout=] allows for powerful track sizing and explicit placement in two axes,
154+
but sometimes a layout only needs alignment of its items in one dimension.
155+
156+
Using a [=masonry container=] together with explicitly-positioned items
157+
allows for this type of one-dimensional grid layout.
158+
159+
<div class="example">
160+
In this example <a href="https://github.com/w3c/csswg-drafts/issues/10233#issuecomment-2071279204">by Douglas Graham</a>,
161+
the items use explicit positioning to place each item into its assigned column;
162+
but there are no rows.
163+
Instead, items in each column stack one after the other.
164+
This layout can't be duplicated in [=grid layout=]
165+
because the “spanning” relationships among the items in adjacent columns
166+
is not fixed: it depends on their relative heights,
167+
and whether the optional banner or advertisement items are included.
168+
It also can't be duplicated in [=flex layout=]
169+
because the source order of the items
170+
(which is used for reading, sequential navigation, and one-column mobile phone layout)
171+
goes back and forth between the two columns.
172+
173+
<figure>
174+
<!-- https://codepen.io/TabAtkins/pen/abeoBOm -->
175+
<img src="images/masonry-page-layout.png"
176+
alt="In one-column layout:
177+
the header, followed by an optional banner, the secondary navigation,
178+
the main content area, an advertisement block, and finally the footer.
179+
In two-column layout:
180+
the header spanning both columns on top,
181+
the footer spanning both columns at the bottom,
182+
in the wider left column the optional banner followed by the main content area,
183+
and in the narrow left column the secondary navigation followed by the advertisement block.">
184+
<figcaption>
185+
Comparison of one-column and two-column variants of a one-dimensional grid page layout.
186+
</figcaption>
187+
</figure>
188+
</div>
189+
144190
<h3 id="alternative-proposals">
145191
Alternative Syntax Proposals</h3>
146192

7.63 KB
Loading

0 commit comments

Comments
 (0)