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
When the height or width of the initial containing block is changed,
1745
1748
they are scaled accordingly.
1746
-
However, when the value of 'overflow' on the root element is ''overflow/auto'',
1747
-
any scroll bars are assumed not to exist.
1748
-
<span class='note'>Note that the initial containing block's size is affected by the presence of scrollbars on the viewport.</span>
1749
1749
1750
-
ISSUE(1766): Level 3 assumes scrollbars never exist because it was hard to implement. This is making authors unhappy.
1750
+
<h5 id="viewport-variants" class="no-toc">
1751
+
The Large, Small, and Dynamic Viewport Sizes</h5>
1752
+
1753
+
There are three variants of the [=viewport-percentage length=] units,
1754
+
corresponding to three (possibly identical) notions of the viewport size.
1755
+
1756
+
<dl export>
1757
+
<dt>large viewport
1758
+
<dd>
1759
+
The <dfn export>large viewport-percentage units</dfn>
1760
+
are defined with respect to the <dfn export>large viewport size</dfn>:
1761
+
the viewport sized assuming
1762
+
any UA interfaces that are dynamically expanded and retracted
1763
+
to be retracted.
1764
+
This allows authors to size content
1765
+
such that it is guaranteed to fill the viewport,
1766
+
noting that such content might be hidden behind such interfaces
1767
+
when they are expanded.
1768
+
1769
+
The sizes of the [=large viewport-percentage units=] are fixed
1770
+
(and therefore stable) unless the viewport itself is resized.
1771
+
1772
+
<div class=example>
1773
+
For example, on phones,
1774
+
where screen real-estate is at a premium,
1775
+
browsers will often hide part or all of the title and address bar
1776
+
once the user starts scrolling the page.
1777
+
The [=large viewport-percentage units=] are sized relative to
1778
+
this larger everything-retracted space,
1779
+
so content using these units will fill the entire visible page
1780
+
when these UI elements are hidden.
1781
+
However, when these retractable elements are shown,
1782
+
they can obscure content
1783
+
that is sized or positioned using these units.
1784
+
</div>
1785
+
1786
+
<dt>small viewport
1787
+
<dd>
1788
+
The <dfn export>small viewport-percentage units</dfn>
1789
+
are defined with respect to the <dfn export>small viewport size</dfn>:
1790
+
the viewport sized assuming
1791
+
any UA interfaces that are dynamically expanded and retracted
1792
+
to be expanded.
1793
+
This allows authors to size content
1794
+
such that it can fit within the viewport
1795
+
even when such interfaces are present,
1796
+
noting that such content might not fill the viewport
1797
+
when such interfaces are retracted.
1798
+
1799
+
The sizes of the [=small viewport-percentage units=] are fixed
1800
+
(and therefore stable) unless the viewport itself is resized.
1801
+
1802
+
<div class=example>
1803
+
An element that is sized as ''height: 100svh'', for example,
1804
+
will fill the screen perfectly,
1805
+
without any of its content being obscured,
1806
+
when all the dynamic UI elements of the UA are shown.
1807
+
1808
+
Once those UI elements start being hidden, however,
1809
+
there will be extra space around the element.
1810
+
The [=small viewport-percentage units=] units are thus “safer” in general,
1811
+
but might not produce the most attractive layout
1812
+
once the user starts interacting with the page.
1813
+
</div>
1814
+
1815
+
<dt>dynamic viewport
1816
+
<dd>
1817
+
The <dfn export>dynamic viewport-percentage units</dfn>
1818
+
are defined with respect to the <dfn export>dynamic viewport size</dfn>:
1819
+
the viewport sized
1820
+
with dynamic consideration of any UA interfaces
1821
+
that are dynamically expanded and retracted.
1822
+
This allows authors to size content
1823
+
such that it can exactly fit within the viewport
1824
+
whether or not such interfaces are present.
1825
+
1826
+
The sizes of the [=dynamic viewport-percentage units=]
1827
+
<em>are not stable</em>
1828
+
even while the viewport itself is unchanged.
1829
+
Using these units can cause content
1830
+
to resize e.g. while the user scrolls the page.
1831
+
Depending on usage,
1832
+
this can be disturbing to the user
1833
+
and/or costly in terms of performance.
1834
+
1835
+
The UA is not required to animate the [=dynamic viewport-percentage units=]
1836
+
while expanding and retracting any relevant interfaces,
1837
+
and may instead calculate the units
1838
+
as if the relevant interface was fully expanded or retracted
1839
+
during the UI animation.
1840
+
(It is recommended that UAs assume the fully-retracted size
1841
+
for this duration.)
1842
+
</dl>
1843
+
1844
+
Whether the expansion/retraction of a particular interface
1845
+
changes the sizes of all of the [=viewport-percentage lengths=]
1846
+
(and the [=initial containing block=])
1847
+
simultaneously
1848
+
or contributes to the differences between
1849
+
the [=large viewport size=] and [=small viewport size=]
1850
+
is largely UA-dependent.
1851
+
However,
1852
+
UAs <em>must</em> categorize as the latter
1853
+
any changes in interface that happen as a result of scrolling
1854
+
or other frequent actions that would disturb the user
1855
+
if they resulted in substantial layout changes.
1856
+
Additionally,
1857
+
UAs may have some dynamically-shown interfaces which intentionally overlay content
1858
+
and do not cause any shifts in layout;
1859
+
typically on-screen keyboards will fit into this category.
1751
1860
1752
1861
For [=paged media=], the exact definition of the viewport-percentage lengths
1753
1862
is deferred to [[!CSS3PAGE]].
1863
+
However, in the typical case of all pages being the same size,
1864
+
they are sized relative to the [=page area=].
1865
+
1866
+
In all cases, scrollbars are assumed not to exist.
1867
+
<span class='note'>Note however that the [=initial containing block=]'s size
1868
+
<em>is</em> affected by the presence of scrollbars on the viewport.</span>
1869
+
1870
+
ISSUE: <a href="https://www.w3.org/TR/css-values-3/#viewport-relative-lengths">Level 3 assumes scrollbars never exist</a> because it was hard to implement
1871
+
and only Firefox bothered to do so.
1872
+
This is <a href="https://github.com/w3c/csswg-drafts/issues/1766#issuecomment-460470368">making authors unhappy</a>.
1873
+
Can we improve here?
1874
+
1875
+
<h5 id="viewport-relative-units" class="no-toc">
1876
+
The Various Viewport-relative Units</h5>
1877
+
1878
+
The [=viewport-percentage length=] units are:
1754
1879
1755
1880
<dl export dfn-type=value dfn-for="<length>">
1756
-
<dt><dfn id="vw" lt="vw">vw unit</dfn>
1881
+
<dt><dfn lt="vw">vw unit</dfn>
1882
+
<dt><dfn lt="svw">svw unit</dfn>
1883
+
<dt><dfn lt="dvw">dvw unit</dfn>
1757
1884
<dd>
1758
-
Equal to 1% of the width of the initial containing block.
1885
+
Equal to 1% of the width of the
1886
+
[=large viewport size=],
1887
+
[=small viewport size=],
1888
+
and [=dynamic viewport size=],
1889
+
respectively.
1759
1890
1760
1891
<div class="example">
1761
1892
In the example below, if the width of the viewport is 200mm,
0 commit comments