@@ -232,6 +232,89 @@ Masonry Layout Model</h2>
232
232
placing each item in the then-shortest row.">
233
233
</table>
234
234
235
+ <h3 id="order-accessibility">
236
+ Reordering and Accessibility</h3>
237
+
238
+ Although [=masonry layout=] generally progresses in a forwards fashion
239
+ (placing the next item down or endward of the current item,
240
+ matching the natural "reading order"),
241
+ it can switch between these two in a seemingly arbitrary manner.
242
+ In simple cases, the 'masonry-slack' property can help reduce
243
+ the feeling of backtracking due to small sizing differences in the [=block axis=]
244
+ when laying out auto-placed items.
245
+ But when [[#masonry-layout-algorithm|auto-placement]] is mixed with [=definite position|explicit placement=] or spanning items,
246
+ some amount of backtracking may occur.
247
+
248
+ <div class=example>
249
+ For example, in the following markup sample,
250
+ the fourth item is a spanner that doesn't fit
251
+ in the remaining empty column on the first line.
252
+ It ends up positioned into the into the first column,
253
+ which is the highest available space into which it will fit.
254
+ The next few items, which have a span of 1,
255
+ end up laying out “above” it in the empty column,
256
+ violating the natural reading order.
257
+
258
+ <xmp highlight=html>
259
+ <section class=masonry>
260
+ <div class=item> 1</div>
261
+ <div class=item> 2</div>
262
+ <div class="item tall"> 3</div>
263
+ <div class="item wide"> 4</div>
264
+ <div class=item> 5</div>
265
+ <div class=item> 6/div>
266
+ <div class=item> 7</div>
267
+ </section>
268
+ <style>
269
+ .masonry {
270
+ display: masonry;
271
+ masonry-tracks: repeat(5, auto);
272
+ }
273
+ .item { height: 50px; }
274
+ .item.wide { masonry-track: span 3; }
275
+ .item.tall { height: 90px; }
276
+ </style>
277
+ </xmp>
278
+
279
+ <figure>
280
+ <img src="images/masonry-reorder-span.png"
281
+ alt="In this example, the first row is items 1, 2, 3, 5, 6,
282
+ with item 3 slightly taller than the others.
283
+ Item 4 spans the first three columns, and is placed
284
+ just below item 3, while item 7 is tucked under item 5.">
285
+ <figcaption> Auto-placed masonry layout with mixed-height items and mixed span sizes</figure>
286
+ </figure>
287
+ Similarly, items explicitly placed into specific tracks can leave gaps behind them,
288
+ into which subsequent auto-placed items can be placed visually out-of-order.
289
+ </div>
290
+
291
+ Authors should be aware of these possibilities
292
+ and design layouts where such backtracking is minimized
293
+ so that focus and reading order can be more easily followed.
294
+ Alternatively, if the items do not have an inherent order,
295
+ use the 'reading-flow' property to allow the UA to re-order the items
296
+ for reading and linear navigation.
297
+
298
+ ISSUE: Or should reordering be the default behavior for auto-placed items here?
299
+
300
+ <div class=note>
301
+ Techniques for reducing backtracking include:
302
+ * Using appropriate values for 'masonry-slack' ,
303
+ i.e. values large enough to avoid gratuitous differentiation among similarly-sized tracks,
304
+ but not so large that meaningful differences get ignored.
305
+ * Using explicit placement in ways that help group related items together,
306
+ rather than ways that disrupt the natural order of items
307
+ * Avoiding the combination of mixed span sizes in the [=grid axis=]
308
+ and disparate item sizes in the [=stacking axis=] ,
309
+ which can cause items to get pulled out of order (see example above).
310
+ </div>
311
+
312
+ As with [=grid layout=] and [=flex layout=]
313
+ authors can use the 'order' property to re-order items;
314
+ the same caveats apply.
315
+ See [[css-grid-2#order-accessibility]]
316
+ and [[css-flexbox-1#order-accessibility]] .
317
+
235
318
<section class="option grid">
236
319
<h3 id="masonry-model-grid-option">
237
320
<span class="option grid">Grid-integrated Option:</span> Establishing Masonry Layout</h3>
0 commit comments