You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Computed value: the keyword ''container-type/none'' or one or more of ''container-type/size'', ''container-type/inline-size'', ''container-type/style'', ''container-type/state''
147
+
Animation type: not animatable
148
+
</pre>
149
+
150
+
Issue: TODO: Bikeshed terms (consider "query" or "context"?)
151
+
152
+
<dl dfn-type=value dfn-for=container-type>
153
+
<dt><dfn>size</dfn>
154
+
<dd>
155
+
Establishes a container for dimensional queries on both the inline and block axis.
156
+
The user agent must change the [=used value=] of the 'contain' property
157
+
so as to turn on [=layout containment=], [=style containment=], and [=size containment=].
158
+
<dt><dfn>inline-size</dfn>
159
+
<dd>
160
+
Establishes a container for dimensional queries on the inline axis.
161
+
The user agent must change the [=used value=] of the 'contain' property
162
+
so as to turn on [=layout containment=], [=style containment=], and [=inline-size containment=].
163
+
<dt><dfn>block-size</dfn>
164
+
<dd>
165
+
Establishes a container for dimensional queries on the block axis.
166
+
The user agent must change the [=used value=] of the 'contain' property
167
+
so as to turn on [=layout containment=], [=style containment=], and [=block-size containment=].
168
+
<dt><dfn>style</dfn>
169
+
<dd>
170
+
Establishes a container for style queries.
171
+
<dt><dfn>state</dfn>
172
+
<dd>
173
+
Establishes a container for state queries.
174
+
</dl>
175
+
176
+
<div class=example>
177
+
Many layouts rely on external sizing for the inline axis,
178
+
while allowing the block axis to auto-size based on content.
179
+
Establishing an ''container/inline-size'' container makes that behavior explicit,
180
+
so that the inline-dimension can be queried,
181
+
without impacting normal layout of the block dimensions:
182
+
183
+
<pre class=lang-css>
184
+
section {
185
+
container: inline-size;
186
+
}
187
+
188
+
h2 { font-size: 1.2em; }
189
+
190
+
@container (width > 40em) {
191
+
h2 { font-size: 1.5em; }
192
+
}
193
+
</pre>
194
+
195
+
The ''em'' value is relative to the <a>computed value</a> of 'font-size'
196
+
on the ''section'' container.
197
+
</div>
198
+
199
+
<div class=example>
200
+
Containers can also expose computed style values for querying.
201
+
This can be useful for toggling behavior across multiple properties:
202
+
203
+
<pre class=lang-css>
204
+
section {
205
+
container: style;
206
+
}
207
+
208
+
@container (--cards == true) {
209
+
article {
210
+
border: thin solid silver;
211
+
border-radius: 0.5em;
212
+
padding: 1em;
213
+
}
214
+
}
215
+
</pre>
216
+
</div>
217
+
218
+
219
+
<h3 id="container-name">
220
+
Naming Containers: the ''container-name'' property</h2>
221
+
222
+
<pre class='propdef'>
223
+
Name: container-name
224
+
Value: none | [ <<custom-ident>> | <<string>> ]+
225
+
Initial: none
226
+
Inherited: no
227
+
Applies to: all elements
228
+
Computed value: the keyword ''container/none'' or a list of custom identifiers
229
+
Animation type: not animatable
230
+
</pre>
231
+
232
+
Issue: TODO: Bikeshed terms (consider "query" or "context"?)
233
+
234
+
<div class=example>
235
+
In some cases, we want to query aspects of a specific container,
236
+
even if it's not the nearest ancestor container.
237
+
For example, we might want to query the height of a main content area,
238
+
and the width of a more nested inline-container.
239
+
240
+
<pre class=lang-css>
241
+
main {
242
+
container-type: size;
243
+
container-name: layout;
244
+
}
245
+
246
+
.grid-item {
247
+
container-type: inline-size;
248
+
container-name: component;
249
+
}
250
+
251
+
@container layout (block-size > 12em) {
252
+
.card { margin-block: 2em; }
253
+
}
254
+
255
+
@container component (inline-size > 30em) {
256
+
.card { margin-inline: 2em; }
257
+
}
258
+
</pre>
259
+
</div>
260
+
261
+
Issue: TODO: Implicit names based on container-type?
262
+
Or a new syntax to query a specific container-type?
263
+
264
+
265
+
<h3 id="container-shorthand">
266
+
Creating Named Containers: the ''container'' shorthand</h2>
267
+
268
+
Issue: TODO: Define the container shorthand
269
+
270
+
Issue: TODO: Bikeshed terms (consider "query" or "context"?)
271
+
272
+
273
+
<h3 id="container-rule">
274
+
Container Queries: the ''@container'' rule</h2>
275
+
276
+
The <dfn at-rule id="at-ruledef-container">@container</dfn> rule
277
+
is a [=conditional group rule=] whose condition is a container query.
278
+
279
+
To parse a <dfn><container-query-list></dfn> production,
280
+
<a>parse a comma-separated list of component values</a>,
281
+
then parse each entry in the returned list as a <<container-condition>>.
282
+
283
+
The syntax of a container condition in the ''@container'' rule
284
+
is similar to that defined for <<media-condition>> in [[MEDIAQUERIES-4]].
0 commit comments