弃用
This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the
兼容性表格
at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.
image-orientation
CSS
property specifies a layout-independent correction to the orientation of an image.
It should
not
be used for any other orientation adjustments; instead, the
transform
property should be used with the
rotate
<transform-function>
.
警告:
This property is deprecated in the specification. Its functionality may be moved into properties on the
<img>
and/or
<picture>
elements, with the possible exception of
from-image
。
flip
and
<angle>
values were made obsolete in Firefox 63.
/* keyword values */
image-orientation: none;
image-orientation: from-image; /* Use EXIF data from the image */
/* Global values */
image-orientation: inherit;
image-orientation: initial;
image-orientation: unset;
/* Obsolete Values. Obsolete since Gecko 63 */
image-orientation: 90deg; /* Rotate 90deg */
image-orientation: 90deg flip; /* Rotate 90deg, and flip it horizontally */
image-orientation: flip; /* No rotation, only applies a horizontal flip */
none
Does not apply any additional image rotation; the image is oriented as encoded or as other CSS property values dictate.
from-image
<angle>
Obsolete since Gecko 63
<angle>
of rotation to apply to the image. It is rounded to the nearest
90deg
(
0.25turn
).
flip
Obsolete since Gecko 63
<angle>
value is applied. If no
<angle>
is given,
0deg
被使用。
This property is intended
only
to be used for the purpose of correcting the orientation of images which were shot with the camera rotated. It should
not
be used for arbitrary rotations. For any purpose other than correcting an image's orientation due to how it was shot or scanned, use a
transform
property with the
rotate
keyword to specify rotation. This includes any user-directed changes to the orientation of the image, or changes required for printing in portrait versus landscape orientation.
If used in conjunction with other CSS properties, such as a
<transform-function>
, any
image-orientation
rotation is applied before any other transformations.
| 初始值 |
0deg
|
|---|---|
| 适用于 | 所有元素 |
| 继承 | yes |
| 计算值 |
an
<angle>
, rounded to the next quarter turn from
0deg
and normalized, that is moduloing the value by
1turn
|
| 动画类型 | discrete |
from-image | <angle> | [ <angle>? flip ]
#image {
image-orientation: from-image; /* Can be changed in the live sample */
}
<img id="image" src="https://yari-demos.prod.mdn.mozit.cloud/files/12668/MDN.svg"
alt="Orientation taken from the image">
<select id="imageOrientation">
<option value="from-image">from-image</option>
<option value="none">none</option>
</select>
var imageOrientation = document.getElementById("imageOrientation");
imageOrientation.addEventListener("change", function (evt) {
document.getElementById("image").style.imageOrientation = evt.target.value;
});
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSS Images Module Level 3
The definition of 'image-orientation' in that specification. |
候选推荐 | 初始定义。 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
image-orientation
Experimental
|
Chrome 完整支持 81 | Edge 完整支持 81 | Firefox 完整支持 26 | IE 不支持 No | Opera 完整支持 67 | Safari 完整支持 13.1 | WebView Android 完整支持 81 | Chrome Android 完整支持 81 | Firefox Android 完整支持 26 | Opera Android 不支持 No | Safari iOS 完整支持 13.4 | Samsung Internet Android 完整支持 13.0 |
flip
&
<angle>
弃用
非标
|
Chrome 不支持 No | Edge 不支持 No | Firefox 不支持 26 — 63 | IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 不支持 No | Firefox Android 不支持 26 — 63 | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 不支持 No |
完整支持
不支持
实验。期望将来行为有所改变。
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
object-fit
,
object-position
,
image-orientation
,
image-rendering
,
image-resolution
.
transform
and
rotate
<gradient>
<image>
image-orientation
image-rendering
object-fit
object-position