|
| 1 | +<pre class='metadata'> |
| 2 | +Title: CSS Images Module Level 5 |
| 3 | +Status: ED |
| 4 | +Work Status: Exploring |
| 5 | +Shortname: css-images |
| 6 | +Level: 5 |
| 7 | +Group: csswg |
| 8 | +ED: https://drafts.csswg.org/css-images-5/ |
| 9 | +TR: https://www.w3.org/TR/css-images-5/ |
| 10 | +Editor: Tab Atkins Jr., Google, http://xanthir.com/contact/, w3cid 42199 |
| 11 | +Editor: Elika J. Etemad / fantasai, Invited Expert, http://fantasai.inkedblade.net/contact, w3cid 35400 |
| 12 | +Editor: Lea Verou, Invited Expert, http://lea.verou.me/about, w3cid 52258 |
| 13 | +Abstract: This module contains the features of CSS level 4 relating to the <<image>> type and replaced elements. |
| 14 | + It includes and extends the functionality of CSS level 2 [[CSS2]] and in the previous level of this specification [[css-images-4]]. |
| 15 | +Default Highlight: css |
| 16 | +</pre> |
| 17 | + |
| 18 | +Introduction {#intro} |
| 19 | +===================== |
| 20 | + |
| 21 | +This is a diff spec over [[!css-images-4]]. |
| 22 | + |
| 23 | +Sizing Images and Objects in CSS {#sizing} |
| 24 | +========================================== |
| 25 | + |
| 26 | +<!-- |
| 27 | + ███████ ██ ██ ████████ |
| 28 | +██ ██ ██ ██ ██ ██ |
| 29 | +██ ██ ██ ██ ██ ██ |
| 30 | +██ ██ ███████ ██ ██ ███████ ████████ |
| 31 | +██ ██ ██ ██ ██ ██ |
| 32 | +██ ██ ██ ██ ██ ██ |
| 33 | + ███████ ███ ████████ |
| 34 | +--> |
| 35 | + |
| 36 | +Setting The Viewbox: the 'object-view-box' property {#the-object-view-box} |
| 37 | +-------------------------------------------------------------------------- |
| 38 | + |
| 39 | + <pre class=propdef> |
| 40 | + Name: object-view-box |
| 41 | + Value: none | <<basic-shape-rect>> |
| 42 | + Initial: none |
| 43 | + Applies to: [=replaced elements=] |
| 44 | + Inherited: no |
| 45 | + Percentages: n/a |
| 46 | + Computed value: specified keyword, or computed <basic-shape> function |
| 47 | + Animation Type: as <basic-shape> if possible, otherwise discrete |
| 48 | + </pre> |
| 49 | + |
| 50 | + The 'object-view-box' property |
| 51 | + specifies a "view box" over an element, |
| 52 | + similar to the <{svg/viewBox|<svg viewBox>}> attribute, |
| 53 | + zooming or panning over the element's contents. |
| 54 | + |
| 55 | + <dl dfn-type=value dfn-for=object-view-box> |
| 56 | + : <dfn>none</dfn> |
| 57 | + :: |
| 58 | + The element does not have a view box. |
| 59 | + |
| 60 | + : <dfn><<basic-shape-rect>></dfn> |
| 61 | + :: |
| 62 | + If the element does not have both a [=natural width=] |
| 63 | + and a [=natural height=], |
| 64 | + this value has no effect, |
| 65 | + similar to ''object-view-box/none''. |
| 66 | + |
| 67 | + Otherwise, specifies a view box for the element. |
| 68 | + |
| 69 | + First, resolve the <<basic-shape-rect>> |
| 70 | + against a [=<basic-shape>/reference box=] formed by the element's |
| 71 | + [=natural sizes=] |
| 72 | + to obtain the element's view box. |
| 73 | + |
| 74 | + For all purposes, |
| 75 | + the element is now treated as having [=natural sizes=] |
| 76 | + equal to the view box's width and height. |
| 77 | + If the element had a [=natural aspect ratio=], |
| 78 | + it's now treated as instead having the same ratio as the view box. |
| 79 | + Further adjustments to the size/position of the element's contents, |
| 80 | + such as 'object-position' or 'object-fit', |
| 81 | + are similarly performed on the view box instead. |
| 82 | + |
| 83 | + When the element is painted, |
| 84 | + its contents are scaled and translated |
| 85 | + such that the element's contents |
| 86 | + retain the same position and size, |
| 87 | + relative to the view box's final size and position, |
| 88 | + that they had when the view box was determined (above). |
| 89 | + |
| 90 | + Issue: Have not yet defined what happens if the view box is zero-area. |
| 91 | + It's an error case, |
| 92 | + so precise behavior isn't important; |
| 93 | + just need to see what impls want to do about it. |
| 94 | + </dl> |
| 95 | + |
| 96 | + Note: Some replaced elements might have a built-in notion of a "view box", |
| 97 | + such as the <{svg}> element. |
| 98 | + Unless otherwise specified, |
| 99 | + this property does not interact with such notions; |
| 100 | + the built-in notion has its effect as normal, |
| 101 | + producing a replaced element with [=natural sizes=], |
| 102 | + then this property applies on top of that. |
| 103 | + |
| 104 | + <div class=example> |
| 105 | + Issue: example here. Need a basic one showing off zooming in, one showing off zooming out, and one showing off interaction with object-fit to display how the parts outside the viewbox can still be painted. |
| 106 | + </div> |
| 107 | + |
0 commit comments