@@ -78,7 +78,7 @@ Strong Containment: the 'contain' property</h2>
78
78
79
79
<pre class='propdef partial'>
80
80
Name : contain
81
- New Values : layout || style || paint || [ size | inline-size | block-size ]
81
+ New Values : layout || style || paint || [ size | inline-size ]
82
82
</pre>
83
83
84
84
<dl dfn-type=value dfn-for=contain>
@@ -87,11 +87,6 @@ Strong Containment: the 'contain' property</h2>
87
87
The value turns on <a>inline-size containment</a> for the element.
88
88
This ensures that the inline [=size containment box|containment box=] can be laid out
89
89
without needing to examine its descendants.
90
- <dt> <dfn>block-size</dfn>
91
- <dd>
92
- The value turns on <a>block-size containment</a> for the element.
93
- This ensures that the block [=size containment box|containment box=] can be laid out
94
- without needing to examine its descendants.
95
90
</dl>
96
91
97
92
@@ -104,21 +99,85 @@ Types of Containment</h2>
104
99
Inline-Size Containment</h3>
105
100
106
101
Giving an element <dfn export>inline-size containment</dfn>
107
- makes its [=principal box=] behave as a [=size containment box=]
108
- on the [=inline axis=] .
109
-
110
- Issue(1031): Define inline-size containment in more detail
102
+ applies [=size containment=] on the element’s [=inline axis=] .
103
+ That means the [=intrinsic size=] of the [=size containment box=]
104
+ on the element’s [=inline axis=]
105
+ is determined as if the element had no content.
106
+ However, content continues to impact the element’s [=block axis=] [=intrinsic size=] .
107
+
108
+ In some cases,
109
+ changes in the [=block size=] can impact layout in the parent formatting context,
110
+ which then impacts the [=inline axis|inline=] [=available space=]
111
+ (e.g. by triggering scrollbars on an ancestor element)
112
+ or the result of [=container size queries=] ,
113
+ which then impacts the element’s [=inline size=] ,
114
+ creating a dependency of this [=inline size=] on the element’s content.
115
+ To prevent infinite cycles,
116
+ if this then results in a different [=block size=] on the element,
117
+ that new [=block size=] can impact the parent formatting context,
118
+ but not in a way that reverts it to the previously-problematic layout.
119
+ For example, if scrollbars were introduced, they are not then removed;
120
+ or if the inline size was reduced, it is not then restored to its previous size.
121
+
122
+ Note: This is similar to the logic governing float placement,
123
+ in which a float whose logical height cannot fit
124
+ is shifted down to find more space,
125
+ which might also give it more inline-axis available space
126
+ and thus produce a shorter float
127
+ whose height could have fit in the initial space,
128
+ but it is not moved back up
129
+ (where it would again be narrower, and thus taller, and thus not fit).
111
130
131
+ <div class=example>
132
+ For example,
133
+ the following <code> article</code> is constrained by both
134
+ the overall <code> section</code> ''width'' ,
135
+ and impacted by the floated <code> div</code> s.
112
136
113
- <h3 id='containment-block-size'>
114
- Block-Size Containment</h3>
115
-
116
- Giving an element <dfn export>block-size containment</dfn>
117
- makes its [=principal box=] behave as a [=size containment box=]
118
- on the [=block axis=] .
137
+ <pre class=lang-css>
138
+ <section style="width: 200px; border: solid; display: flow-root;">
139
+ <!-- floated elements that impact the available space -->
140
+ <div style="float: left; width: 50px; height: 80px; background: red;"></div>
141
+ <div style="float: right; width: 50px; height: 80px; background: red;"></div>
142
+ <div style="float: left; width: 160px; height: 80px; background: red;"></div>
143
+
144
+ <!-- parent layout, determining context -->
145
+ <article style="border: solid; display: flow-root; min-width: min-content;">
146
+ <header style="background: orange; aspect-ratio: 1/1;">
147
+ <h4 style="margin:0;">Article Title</h4>
148
+ </header>
149
+ </article>
150
+ </section>
151
+ </pre>
119
152
120
- Issue(1031): Define block-size containment in more detail
153
+ The block layout algorithm will attempt to layout the <code> article</code>
154
+ in the first available space between the first two floated <code> div</code> s.
155
+ However, the <code> header</code> ''aspect-ratio''
156
+ requires a space with ''height'' equal or greater to the ''width'' ,
157
+ and the available space is 100px wide by 80px tall,
158
+ so the <code> article</code> is unable to fit.
159
+ As a result, the block layout algorithm moves on,
160
+ and attempts to layout the <code> article</code> in the next available space.
161
+
162
+ Since <code> article</code> ''min-width'' depends on the ''min-ccontent'' size,
163
+ it will likley be too large to fit in the 40px wide space
164
+ beside the final floated <code> div</code> ,
165
+ and continue to layout below that <code> div</code> as well--
166
+ forming a 200px square below all the floated elements.
167
+
168
+ However, if the ''min-width'' is removed from the <code> article</code> ,
169
+ or if [=inline-size containment=] is added to
170
+ either the <code> article</code> or <code> header</code> ,
171
+ then the <code> article</code> will fit as a 40px square
172
+ next to the final floated <code> div</code> .
173
+ Even though this resulting size could also fit in the initial space,
174
+ agents do not backtrack
175
+ and attempt to place the <code> article</code>
176
+ in a context that previously failed.
177
+ </div>
121
178
179
+ Issue(1031): Define inline-size containment in more detail
180
+ (including additional examples)
122
181
123
182
<h2 id="container-queries">
124
183
Container Queries</h2>
@@ -190,31 +249,23 @@ Creating Query Containers: the 'container-type' property</h3>
190
249
<dl dfn-type=value dfn-for=container-type>
191
250
<dt> <dfn>size</dfn>
192
251
<dd>
193
- Establishes a [=query container=] for [=size queries=]
252
+ Establishes a [=query container=] for [=container size queries=]
194
253
on both the [=inline axis|inline=] and [=block axis=] .
195
254
Applies [=layout containment=] ,
196
255
[=style containment=] ,
197
256
and [=size containment=]
198
257
to the [=principal box=] .
199
258
<dt> <dfn>inline-size</dfn>
200
259
<dd>
201
- Establishes a [=query container=] for [=size queries=]
260
+ Establishes a [=query container=] for [=container size queries=]
202
261
on the container’s own [=inline axis=] .
203
262
Applies [=layout containment=] ,
204
263
[=style containment=] ,
205
264
and [=inline-size containment=]
206
265
to the [=principal box=] .
207
- <dt> <dfn>block-size</dfn>
208
- <dd>
209
- Establishes a [=query container=] for [=size queries=]
210
- on the container’s own [=block axis=] .
211
- Applies [=layout containment=] ,
212
- [=style containment=] ,
213
- and [=block-size containment=]
214
- to the [=principal box=] .
215
266
<dt> <dfn>style</dfn>
216
267
<dd>
217
- Establishes a [=query container=] for [=style queries=] .
268
+ Establishes a [=query container=] for [=container style queries=] .
218
269
<dt> <dfn>state</dfn>
219
270
<dd>
220
271
Establishes a [=query container=] for [=state queries=] .
@@ -374,7 +425,7 @@ Container Queries: the ''@container'' rule</h3>
374
425
The <dfn at-rule id="at-ruledef-container">@container</dfn> rule
375
426
is a [=conditional group rule=] whose condition is
376
427
a <dfn export>container query</dfn> ,
377
- which is a boolean combination of [=size queries=] and/or [=style queries=] .
428
+ which is a boolean combination of [=container size queries=] and/or [=container style queries=] .
378
429
Style declarations within the <<stylesheet>> block of an ''@container'' rule
379
430
are [[css-cascade-4#filtering|filtered]] by its condition
380
431
to only match when the [=container query=]
@@ -432,7 +483,7 @@ Container Queries: the ''@container'' rule</h3>
432
483
is a match for both ''container-type/inline-size'' and ''container-type/block-size'' .
433
484
434
485
Once an eligible [=query container=] has been selected for an element,
435
- each [=container feature=] in the <<container-query-list >>
486
+ each [=container feature=] in the <<container-condition >>
436
487
is evaluated against that [=query container=] .
437
488
If the selected [=query container=]
438
489
is not a valid 'container-type' for the feature,
@@ -451,14 +502,14 @@ Container Queries: the ''@container'' rule</h3>
451
502
452
503
The styles above will only be applied
453
504
if there nearest ancestor container named "card"
454
- meets both the '@container/inline-size' and [=style queries |style=] conditions.
505
+ meets both the '@container/inline-size' and [=container style query |style=] conditions.
455
506
</div>
456
507
457
508
Style rules defined on an element inside multiple nested [=container queries=]
458
509
apply when all of the wrapping [=container queries=] are true for that element.
459
510
460
511
Note: Nested [=container queries=] can evaluate in relation to different containers,
461
- so it is not always possible to merge the individual <<container-query-list >> s
512
+ so it is not always possible to merge the individual <<container-condition >> s
462
513
into a single query.
463
514
464
515
<h3 id="animated-containers">
@@ -534,7 +585,7 @@ Container Features</h2>
534
585
<h3 id="size-container">
535
586
Size Container Features</h3>
536
587
537
- A <dfn export>size query</dfn>
588
+ A <dfn export>container size query</dfn>
538
589
(syntactically represented as <<size-query>> )
539
590
allows querying
540
591
the size of the [=query container=] ’s [=principal box=] .
@@ -550,7 +601,7 @@ Size Container Features</h3>
550
601
551
602
If the [=query container=] does not have a [=principal box=] ,
552
603
or the principal box is not a [=layout containment box=] ,
553
- or the [=query container=] does not support [=size queries=] on the relevant axes,
604
+ or the [=query container=] does not support [=container size queries=] on the relevant axes,
554
605
then the result of evaluating the [=size feature=] is unknown.
555
606
556
607
[=Relative length=] units in [=container query=] conditions
@@ -685,7 +736,7 @@ Orientation: the '@container/orientation' feature</h4>
685
736
<h3 id="style-container">
686
737
Style Container Features</h3>
687
738
688
- A <dfn export>style queries </dfn>
739
+ A <dfn export>container style query </dfn>
689
740
(syntactically represented by <<style-query>> )
690
741
allows querying
691
742
the [=computed values=] of the [=query container=] .
@@ -749,11 +800,11 @@ Container Relative Lengths: the ''cqw'', ''cqh'', ''cqi'', ''cqb'', ''cqmin'', '
749
800
750
801
For each element,
751
802
[=container query length=] units are evaluated
752
- as [=size queries=] on the relevant axis (or axes)
803
+ as [=container size queries=] on the relevant axis (or axes)
753
804
described by the unit.
754
805
The [=query container=] for each axis
755
806
is the nearest ancestor container
756
- that accepts [=size queries=] on that axis.
807
+ that accepts [=container size queries=] on that axis.
757
808
If no eligible [=query container=] is available,
758
809
then use the [=small viewport size=] for that axis.
759
810
0 commit comments