Skip to content

Commit 8d636cc

Browse files
committed
[css-values-5][editorial] Add example, rephrase. #6245
1 parent ef0d213 commit 8d636cc

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

css-values-5/Overview.bs

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,57 @@ Interpolation Mapping Notations: the *-interpolate() family</h2>
10121012
* |stop| represents an [=interpolation stop=]; see [[#interpolation-map-arguments]]
10131013
* |between-options| specifies options for the interpolation between the two surrounding stops.
10141014

1015+
<div class=example>
1016+
For example,
1017+
the following changes the background color of an element
1018+
depending on the width of the viewport:
1019+
1020+
<pre highlight=css>
1021+
background: color-interpolate(100vw in lch,
1022+
200px: palegoldenrod,
1023+
800px: palegreen,
1024+
2000px: powderblue
1025+
);
1026+
</pre>
1027+
1028+
* Below ''200px'', the color is ''palegoldenrod'';
1029+
* From ''200px'' to ''800px'',
1030+
the color interpolates in ''lch''
1031+
from ''palegoldenrod'' to ''palegreen'';
1032+
* From ''800px'' to ''2000px'',
1033+
the color interpolate in ''lch''
1034+
from ''palegreen'' to ''powderblue'';
1035+
* Above ''2000px'', the color is ''powderblue''.
1036+
</div>
1037+
1038+
<div class=example>
1039+
In the following example,
1040+
the font size interpolates from a smaller size on small screens
1041+
to a larger size on large screens,
1042+
easing along the interpolation curve.
1043+
The author is storing the progress scale in a custom property
1044+
to be able to re-use it across multiple 'font-size' declarations
1045+
throughout the document.
1046+
1047+
<pre highlight=css>
1048+
html {
1049+
--font-scale: progress(100vw, 200px, 2000px) ease-in-out;
1050+
font-size: calc-interpolate(var(--font-scale),
1051+
0%: 16px,
1052+
70%: 20px,
1053+
100%: 24px);
1054+
}
1055+
h1 {
1056+
font-size: calc-interpolate(var(--font-scale),
1057+
0%: 1.2rem,
1058+
40%: 2rem,
1059+
100%: 3rem);
1060+
}
1061+
</pre>
1062+
1063+
ISSUE: If anyone has better examples to punch in here let us know...
1064+
</div>
1065+
10151066
The [=interpolation notations=] in CSS include:
10161067
* ''calc-interpolate()'',
10171068
for interpolating <<number>>, <<length>>, <<percentage>>, <<time>>,
@@ -1179,6 +1230,7 @@ Defining the Interpolation Map</h4>
11791230
When appearing in the first argument,
11801231
provides any type-specific interpolation options
11811232
that apply to every segment in the [=interpolation map=].
1233+
(For example, ''color-interpolate()'' allows <<color-interpolation-method>>.)
11821234
When appearing between stops,
11831235
provides any type-specific interpolation options
11841236
that apply to the interpolation segment between
@@ -1224,9 +1276,9 @@ Calculating the Absolute Interpolation Range</h4>
12241276

12251277
In an [=absolutely=] typed [=interpolation map=],
12261278
the first and last [=absolute=] stops in the list
1227-
are pinned to 0% and 100%, respectively.
1279+
are assigned to 0% and 100%, respectively.
12281280
(If there is only one [=absolutely=] typed [=interpolation stop=],
1229-
it is pinned to both 0% and 100%.)
1281+
it is assigned to both 0% and 100%.)
12301282

12311283
A [=proportionally=] typed [=interpolation map=]
12321284
does not define an [=interpolation range=].

0 commit comments

Comments
 (0)