我們的志工尚未將本文翻譯為 正體中文 (繁體) 版本。加入我們,幫忙翻譯!
您也可以閱讀本文的 English (US) 版本。

The 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>.

Warning: This property is likely to be deprecated in the near future, with its functionality moved into properties on the <img> and/or <picture> elements, with the possible exception of from-image. The flip and <angle> values were made obsolete as of FF63.

/* 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 */

Initial value0deg
Applies toall elements
Inheritedyes
Mediavisual
Computed valuean <angle>, rounded to the next quarter turn from 0deg and normalized, that is moduloing the value by 1turn
Animation typediscrete
Canonical orderthe unique non-ambiguous order defined by the formal grammar

Syntax

Values

none
Default initial value. Will not apply any additional image rotation: the image is oriented as encoded or as other CSS property values dictate.
from-image
The EXIF information contained in the image will be used to rotate the image appropriately.
<angle> Obsolete since Gecko 63
The <angle> of rotation to apply to the image. It is rounded to the nearest 90deg (0.25turn).
flip Obsolete since Gecko 63
The image is flipped horizontally (i.e., reflected) after the rotation given by the <angle> value is applied. If no <angle> is given, 0deg is used.

Formal syntax

from-image | <angle> | [ <angle>? flip ]

Usage notes

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.

Example

CSS

#image {
  image-orientation: from-image; /* Can be changed in the live sample */
}

Result

Specifications

Specification Status Comment
CSS Images Module Level 4
The definition of 'image-orientation' in that specification.
Working Draft The from-image and flip keywords have been added.
CSS Images Module Level 3
The definition of 'image-orientation' in that specification.
Candidate Recommendation Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic support
Experimental
Chrome No support NoEdge ? Firefox Full support 26IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android ? Edge Mobile ? Firefox Android Full support 26Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support No
flip & <angle>
DeprecatedNon-standard
Chrome No support NoEdge ? Firefox No support 26 — 63IE No support NoOpera No support NoSafari No support NoWebView Android No support NoChrome Android ? Edge Mobile ? Firefox Android No support 26 — 63Opera Android No support NoSafari iOS No support NoSamsung Internet Android No support No

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
Non-standard. Expect poor cross-browser support.
Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.
Deprecated. Not for use in new websites.

See also