Skip to content

Commit 43db5f6

Browse files
committed
[css-images-4] Make scale-down a flag for cover/contain
Resolves #1578
1 parent 480afc2 commit 43db5f6

File tree

1 file changed

+105
-1
lines changed

1 file changed

+105
-1
lines changed

css-images-4/Overview.bs

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1438,7 +1438,111 @@ Gradient Color-Stops
14381438
Sizing Images and Objects in CSS {#sizing}
14391439
==========================================
14401440

1441-
Note: No change from [[css3-images]].
1441+
1450+
1451+
Sizing Objects: the 'object-fit' property {#the-object-fit}
1452+
-----------------------------------------------------------
1453+
1454+
1455+
Name: object-fit
1456+
Value: fill | none | [contain | cover] || scale-down
1457+
Initial: fill
1458+
Applies to: replaced elements
1459+
Inherited: no
1460+
Percentages: n/a
1461+
Media: visual
1462+
Computed value: specified value
1463+
Animatable: no
1464+
1465+
1466+
The 'object-fit' property specifies how the contents of a replaced element
1467+
should be fitted to the box established by its used height and width.
1468+
1469+
1470+
fill
1471+
1472+
The replaced content is sized to fill the element's content box:
1473+
the object's concrete object size is the element's used width and height.
1474+
1475+
none
1476+
1477+
The replaced content is not resized to fit inside the element's content box:
1478+
determine the object's concrete object size
1479+
using the default sizing algorithm with no specified size,
1480+
and a default object size equal to the replaced element's used width and height.
1481+
1482+
contain
1483+
1484+
The replaced content is sized to maintain its aspect ratio
1485+
while fitting within the element's content box:
1486+
1487+
against the element's used width and height.
1488+
1489+
If the ''scale-down'' flag is used, size the content as if ''object-fit/none'' or ''object-fit/contain'' were specified,
1490+
whichever would result in a smaller concrete object size.
1491+
1492+
Note: Both ''object-fit/none'' and ''object-fit/contain'' respect the content's intrinsic aspect ratio,
1493+
so the concept of "smaller" is well-defined.
1494+
1495+
cover
1496+
1497+
The replaced content is sized to maintain its aspect ratio
1498+
while filling the element's entire content box:
1499+
1500+
against the element's used width and height.
1501+
1502+
If the ''scale-down'' flag is used, size the content as if ''object-fit/none'' or ''object-fit/cover'' were specified,
1503+
whichever would result in a smaller concrete object size.
1504+
1505+
Note: Both ''object-fit/none'' and ''object-fit/cover'' respect the content's intrinsic aspect ratio,
1506+
so the concept of "smaller" is well-defined.
1507+
1508+
scale-down
1509+
1510+
Equivalent to ''contain scale-down''.
1511+
1512+
1513+
If the content does not completely fill the replaced element's content box,
1514+
the unfilled space shows the replaced element's background.
1515+
Since replaced elements always clip their contents to the content box,
1516+
the content will never overflow.
1517+
See the 'object-position' property for positioning the object with respect to the content box.
1518+
1519+
1520+
1521+
1522+
1523+
An example showing how four of the values of 'object-fit' cause the replaced element (blue figure)
1524+
to be scaled to fit its height/width box (shown with a green background),
1525+
using the initial value for 'object-position'.
1526+
In this case, ''scale-down'' and ''scale-down contain'' would look identical to ''object-fit/contain'',
1527+
and ''scale-down cover'' would look identical to ''object-fit/none''.
1528+
1529+
1530+
1531+
Note: The 'object-fit' property has similar semantics to
1532+
the fit attribute in [[SMIL10]]
1533+
and the <> parameter
1534+
on the preserveAspectRatio attribute in [[SVG11]].
1535+
1536+
Note: Per the object size negotiation algorithm,
1537+
1538+
(or, in this case, the size of the content)
1539+
does not directly scale the object itself -
1540+
it is merely passed to the object as information about the size of the visible canvas.
1541+
How to then draw into that size is up to the image format.
1542+
In particular, raster images always scale to the given size,
1543+
while SVG uses the given size as the size of the "SVG Viewport"
1544+
(a term defined by SVG)
1545+
and then uses the values of several attributes on the root <svg> element to determine how to draw itself.
14421546

14431547
Image Processing {#image-processing}
14441548
====================================

0 commit comments

Comments
 (0)