Skip to content

Commit 020c2b8

Browse files
committed
[css-contain] Notes and examples about aspect ratio and size containment
Closes #5550
1 parent 4ed84ed commit 020c2b8

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

css-contain-1/Overview.bs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ spec:css-break-3; type:dfn; text:fragmentation container
4040
spec:css-break-3; type:dfn; text:fragmentation context
4141
spec:css-break-3; type:dfn; text:fragmented flow
4242
spec:css2; type:value; property: height; text:auto
43+
spec:css-sizing-4; type:property; text:aspect-ratio
4344
</pre>
4445

4546
<h2 id='intro'>
@@ -498,6 +499,30 @@ Size Containment</h3>
498499
2. [=Size containment boxes=] must be treated
499500
as if they had no [=intrinsic aspect ratio=].
500501

502+
Note: Size containment only suppresses the [=intrinsic aspect ratio=],
503+
not [=preferred aspect ratio=],
504+
so properties like 'aspect-ratio' which affect that [=preferred aspect ratio=] directly
505+
are honored.
506+
507+
<div class=example>
508+
Given the following markup and style, the image would be sized to 100px by 100px,
509+
as the aspect ratio set by the 'aspect-ratio' property takes effect.
510+
<pre><code class=lang-css>
511+
img {
512+
width: 100px;
513+
aspect-ratio: 1/1;
514+
contain: size;
515+
}
516+
</code><code class=lang-html>
517+
&lt;img src="https://www.example.com/300x100.jpg">
518+
</code></pre>
519+
520+
If the 'aspect-ratio' property had not been declared,
521+
the image would have been 100px by 0px,
522+
as its intrinsic aspect ratio is suppressed,
523+
and its intrinsic height is treated as 0.
524+
</div>
525+
501526
3. [=Size containment boxes=] are <a spec=css-break-3>monolithic</a> (See [[CSS-BREAK-3#possible-breaks]]).
502527

503528
<wpt>

css-contain-2/Overview.bs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ spec:css-break-3; type:dfn; text:fragmentation container
4343
spec:css-break-3; type:dfn; text:fragmentation context
4444
spec:css-break-3; type:dfn; text:fragmented flow
4545
spec:css-sizing-4; type:property; text:contain-intrinsic-size
46+
spec:css-sizing-4; type:property; text:aspect-ratio
4647
spec:intersection-observer; type:dfn; text:intersection root
4748
spec:css-sizing-3; type:value; for:height; text:auto
4849
</pre>
@@ -546,6 +547,30 @@ Size Containment</h3>
546547
2. [=Size containment boxes=] must be treated
547548
as if they had no [=intrinsic aspect ratio=].
548549

550+
Note: Size containment only suppresses the [=intrinsic aspect ratio=],
551+
not [=preferred aspect ratio=],
552+
so properties like 'aspect-ratio' which affect that [=preferred aspect ratio=] directly
553+
are honored.
554+
555+
<div class=example>
556+
Given the following markup and style, the image would be sized to 100px by 100px,
557+
as the aspect ratio set by the 'aspect-ratio' property takes effect.
558+
<pre><code class=lang-css>
559+
img {
560+
width: 100px;
561+
aspect-ratio: 1/1;
562+
contain: size;
563+
}
564+
</code><code class=lang-html>
565+
&lt;img src="https://www.example.com/300x100.jpg">
566+
</code></pre>
567+
568+
If the 'aspect-ratio' property had not been declared,
569+
the image would have been 100px by 0px,
570+
as its intrinsic aspect ratio is suppressed,
571+
and its intrinsic height is treated as 0.
572+
</div>
573+
549574
3. [=Size containment boxes=] are <a spec=css-break-3>monolithic</a> (See [[CSS-BREAK-3#possible-breaks]]).
550575

551576
<wpt>

0 commit comments

Comments
 (0)