Skip to content

Commit 00763c4

Browse files
committed
[css-gaps-1] Clarify flexbox behavior with examples
1 parent 6c3b559 commit 00763c4

6 files changed

+86
-12
lines changed

css-gaps-1/Overview.bs

+86-12
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,19 @@ Layout and painting {#layout-painting}
151151
</figcaption>
152152
</div>
153153

154+
Note: [[CSS-ALIGN-3#column-row-gap]] defines
155+
cross-direction gaps in flex containers
156+
as being between adacent flex items in a single line.
157+
Thus, in the example above,
158+
even though the right edges of #4 and #7 line up,
159+
and the left edges of #5 and #8 line up,
160+
the spaces between those two pairs of items are <em>two distinct gaps</em>
161+
since they are on different lines.
162+
Therefore, the intersection between #4, #5, #7, and #8
163+
contains two <a>gap intersection points</a> whose locations coincide:
164+
one at the bottom of the gap between #4 and #5,
165+
and one at the top of the gap between #7 and #8.
166+
154167
<a>Gap decorations</a> are painted relative to pairs of <a>gap intersection points</a>,
155168
in the center of the corresponding gap and parallel to its edges.
156169

@@ -305,42 +318,103 @@ Breaking gap decorations into segments: The 'column-rule-break', 'row-rule-break
305318

306319
<div class="example">
307320
<pre>
308-
.break-intersection {
309-
rule-break: intersection;
321+
.break-none-grid {
322+
display: grid;
323+
grid-template: repeat(4, 100px) / repeat(4, 100px);
324+
gap: 20px;
325+
row-rule: 6px solid red;
326+
column-rule: 6px solid blue;
327+
rule-break: none;
310328
rule-outset: 0px;
311329
}
312330
</pre>
313-
<img src="images/example-break-intersection.png">
331+
<img src="images/example-break-none-grid.png">
314332
<figcaption>
315-
<a>Gap decorations</a> broken at every <a>gap intersection point</a>.
333+
Grid <a>gap decorations</a> with no breaks.
334+
Note that the <a>gap decorations</a> extend "behind" items placed in the grid.
316335
</figcaption>
317336
</div>
318337

319338
<div class="example">
320339
<pre>
321-
.break-spanning-item {
340+
.break-spanning-item-grid {
341+
display: grid;
342+
grid-template: repeat(4, 100px) / repeat(4, 100px);
343+
gap: 20px;
344+
row-rule: 6px solid red;
345+
column-rule: 6px solid blue;
322346
rule-break: spanning-item;
323347
rule-outset: 0px;
324348
}
325349
</pre>
326-
<img src="images/example-break-spanning-item.png">
350+
<img src="images/example-break-spanning-item-grid.png">
327351
<figcaption>
328-
<a>Gap decorations</a> broken at <a>gap intersection points</a>
329-
that are not adjacent to a spanning item.
352+
Grid <a>gap decorations</a> broken at <a>gap intersection points</a>
353+
that are not adjacent to spanning items.
330354
</figcaption>
331355
</div>
332356

333357
<div class="example">
334358
<pre>
335-
.break-none {
359+
.break-intersection-grid {
360+
display: grid;
361+
grid-template: repeat(4, 100px) / repeat(4, 100px);
362+
gap: 20px;
363+
row-rule: 6px solid red;
364+
column-rule: 6px solid blue;
365+
rule-break: intersection;
366+
rule-outset: 0px;
367+
}
368+
</pre>
369+
<img src="images/example-break-intersection-grid.png">
370+
<figcaption>
371+
Grid <a>gap decorations</a> broken at every <a>gap intersection point</a>
372+
that is not flanked by spanning items on opposing sides.
373+
</figcaption>
374+
</div>
375+
376+
<div class="example">
377+
<pre>
378+
.break-none-flex {
379+
display: flex;
380+
flex-wrap: wrap;
381+
gap: 20px;
382+
row-rule: 6px solid red;
383+
column-rule: 6px solid blue;
336384
rule-break: none;
337385
rule-outset: 0px;
338386
}
339387
</pre>
340-
<img src="images/example-break-none.png">
388+
<img src="images/example-break-none-flex.png">
341389
<figcaption>
342-
<a>Gap decorations</a> with no breaks.
343-
Note that the <a>gap decorations</a> extend "behind" items placed in the grid.
390+
Flexbox <a>gap decorations</a> with no breaks.
391+
Note that each flex line has its own distinct gaps.
392+
Therefore, <a>gap decorations</a> in adjacent flex lines
393+
are separate from each other even if the gaps happen to line up.
394+
</figcaption>
395+
</div>
396+
397+
Note: Because flexbox has no concept of spanning items,
398+
''column-rule-break/spanning-item'' on a flexbox has the same effect as
399+
''column-rule-break/none''.
400+
401+
<div class="example">
402+
<pre>
403+
.break-intersection-flex {
404+
display: flex;
405+
flex-wrap: wrap;
406+
gap: 20px;
407+
width: 500px;
408+
gap: 20px;
409+
row-rule: 6px solid red;
410+
column-rule: 6px solid blue;
411+
rule-break: intersection;
412+
rule-outset: 0px;
413+
}
414+
</pre>
415+
<img src="images/example-break-intersection-flex.png">
416+
<figcaption>
417+
Flexbox <a>gap decorations</a> broken at every <a>gap intersection point</a>.
344418
</figcaption>
345419
</div>
346420

Loading
5.37 KB
Loading

0 commit comments

Comments
 (0)