Skip to content

Commit 5e2b011

Browse files
committed
[css-sizing-4] Add definition of stretch-fit sizing.
1 parent fdd0aba commit 5e2b011

1 file changed

Lines changed: 62 additions & 4 deletions

File tree

css-sizing-4/Overview.bs

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ Intrinsic Aspect Ratios: the 'aspect-ratio' property</h3>
284284
layout rules specific to [=replaced elements=] generally
285285
do not apply to [=non-replaced=] boxes with a [=preferred aspect ratio=].
286286
For example, a [=non-replaced=] [=absolutely-positioned=] box
287-
treats ''justify-self: normal'' as ''stretch'', not as ''start''
287+
treats ''justify-self: normal'' as ''justify-self/stretch'', not as ''justify-self/start''
288288
([[CSS-ALIGN-3#justify-abspos]]).
289289

290290
ISSUE: CSS2.1 does not cleanly differentiate between
@@ -573,12 +573,70 @@ Intrinsic Size Contributions</h2>
573573
<h2 id='extrinsic'>
574574
Extrinsic Size Determination</h2>
575575

576-
576+
ISSUE: [[css-sizing-3#extrinsic]]
577577

578578
<h3 id="stretch-fit-sizing">
579-
Stretch-fit Sizing</h3>
579+
Stretch-fit Sizing: filling the containing block</h3>
580+
581+
Stretch-fit sizing tries to set the box’s used size
582+
to the length necessary
583+
to make its outer size as close to filling the [=containing block=] as possible
584+
while still respecting the constraints imposed by min-height/min-width/max-height/max-width.
585+
586+
Formally, its behavior is the same as specifying an [=automatic size=]
587+
together with a [=self-alignment property=] value of ''width/stretch''
588+
(in the relevant axis),
589+
except that the resulting box,
590+
which can end up not exactly fitting its [=alignment container=],
591+
can be subsequently aligned by its actual [=self-alignment property=] value.
592+
593+
Additionally,
594+
in [=formatting contexts=] and axes in which the relevant [=self-alignment property=] does not apply
595+
(such as the block axis in Block Layout, or the main axis in Flex Layout),
596+
[=stretch-fit sizing=] still has the effect
597+
of causing the box to attempt to fill its containing block,
598+
invoking the percentage size calculations but applying that size to its margin box
599+
instead of the box indicated by 'box-sizing'.
600+
For this purpose, ''margin/auto'' margins are treated as zero,
601+
and furthermore, for [=block-level boxes=] in particular,
602+
if its block-start/block-end [=margin=]
603+
would be adjoining to its parent's block-start/block-end [=margin=]
604+
if its parent’s [=sizing properties=] all had their [=initial values=],
605+
then its block-start/block-end [=margin=] is treated as zero.
580606

581-
607+
<div class="example">
608+
For example, given the following HTML representing two [=block boxes=]:
609+
<pre class=html>
610+
&lt;div class="outer">
611+
&lt;div class="inner">&lt;/div>
612+
&lt;/div>
613+
</pre>
614+
615+
In the following case,
616+
the [=outer height=] of the inner box
617+
will exactly match the height of the outer box (200px),
618+
but its [=inner height=] will be 20px less, to account for its margins.
619+
620+
<pre>
621+
.outer { height: 200px; border: solid; }
622+
.inner { height: stretch; margin: 10px; }
623+
</pre>
624+
625+
In the following case,
626+
the height of the inner box
627+
will exactly match the height of the outer box (200px).
628+
The top margins will collapse,
629+
but the bottom margins do not collapse
630+
(because the bottom margin of a box is not adjoining
631+
to the bottom margin of a parent with a non-''height/auto'' height,
632+
see [[CSS2/box#collapsing-margins]]),
633+
and therefore the inner box’s bottom margin will be truncated.
634+
635+
<pre>
636+
.outer { height: 200px; margin: 0; }
637+
.inner { height: stretch; margin: 10px; }
638+
</pre>
639+
</div>
582640

583641
<h3 id="contain-fit-sizing">
584642
Contain-fit Sizing: stretching while maintaining an aspect ratio</h3>

0 commit comments

Comments
 (0)