Skip to content

Commit a819e21

Browse files
committed
[css-sizing-4] Define the interaction of c-i-s and scrollbars, per WG resolution. Fixes w3c#4415.
1 parent c6f083d commit a819e21

File tree

1 file changed

+78
-2
lines changed

1 file changed

+78
-2
lines changed

css-sizing-4/Overview.bs

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ Overriding Contained Intrinsic Sizes: the 'contain-intrinsic-size' property</h3>
479479
Percentages: n/a
480480
Animation type: by computed value type
481481
</pre>
482-
482+
483483
This property allows elements with [=size containment=] to specify
484484
an <dfn export>explicit intrinsic inner size</dfn>,
485485
causing the box to size as if its in-flow content
@@ -504,7 +504,7 @@ Overriding Contained Intrinsic Sizes: the 'contain-intrinsic-size' property</h3>
504504
while still allowing it to size as if it had content.
505505

506506
Values are defined as:
507-
507+
508508
<dl dfn-type=value dfn-for="contain-intrinsic-size">
509509
: <dfn>none</dfn>
510510
::
@@ -521,6 +521,82 @@ Overriding Contained Intrinsic Sizes: the 'contain-intrinsic-size' property</h3>
521521
it defaults to the same value as the first.
522522
</dl>
523523

524+
<h4 id='cis-scrollbars'>
525+
Interaction With ''overflow: auto''</h4>
526+
527+
The 'contain-intrinsic-size' property provides an estimate
528+
of how large the author expects the content of an element to be,
529+
but this estimate is not actual content
530+
and does not represent anything that needs to be shown to the user.
531+
Therefore, an element with ''overflow: auto'' must not generate scrollbars
532+
as a consequence of 'contain-intrinsic-size'.
533+
534+
However, if 'contain-intrinsic-size' indicates a size large enough
535+
that the element would generate scrollbars
536+
if it contained actual content of that size,
537+
then the element must be <em>sized</em> as if it generated those scrollbar(s)
538+
in accordance with such hypothetical content.
539+
540+
<div class='example'>
541+
In the following example code:
542+
543+
<pre highlight=css>
544+
div {
545+
width: max-content;
546+
contain-intrinsic-size: 100px 100px;
547+
overflow: auto;
548+
}
549+
</pre>
550+
551+
The element ends up being ''100px'' wide and ''100px'' tall:
552+
'contain-intrinsic-size' provides the max-content width,
553+
and also the height.
554+
555+
If the element then ended up with content that was ''150px'' tall,
556+
it would show a vertical scrollbar;
557+
if the scrollbar is not overlay,
558+
it will take up some of that ''100px'' width,
559+
leaving a smaller amount
560+
(roughly ''84px'', typically)
561+
for the content to flow into.
562+
(See [[css-overflow-3#scrollbar-layout]].)
563+
564+
Even though there's now less than ''100px'' of horizontal space available for the content,
565+
it will not generate a horizontal scrollbar just because 'contain-intrinsic-size' indicates a ''100px'' width;
566+
that would only happen if the actual content
567+
had something unbreakable
568+
and wider than the remaining space.
569+
</div>
570+
571+
<div class=example>
572+
In contrast, in the following example code:
573+
574+
<pre highlight=css>
575+
div {
576+
width: max-content;
577+
contain-intrinsic-size: 100px 100px;
578+
height: 50px;
579+
overflow: auto;
580+
}
581+
</pre>
582+
583+
The element has a fixed ''50px'' height,
584+
but 'contain-intrinsic-size' indicates a ''100px'' “estimated content height”.
585+
The element thus assumes that it will need a vertical scrollbar
586+
when it's filled with actual content,
587+
resulting in a max-content width a little more than ''100px''
588+
(roughly ''116px'', typically),
589+
to accommodate the estimated ''100px'' of max-content width from 'contain-intrinsic-size',
590+
and as well as the vertical scrollbar width (roughly ''16px'', typically).
591+
592+
However, even though the element reserves space on the assumption of needing a scrollbar,
593+
it will not actually generate one
594+
unless the actual content overflows:
595+
if it ends up containing content that's less than 50px tall,
596+
no vertical scrollbar will be generated at all,
597+
but the element will still be ''116px'' wide.
598+
</div>
599+
524600

525601
<!--
526602
██████ ███████ ██ ██ ████████ ████████ ████ ████████ ██████

0 commit comments

Comments
 (0)