image-orientation - CSS: Cascading Style Sheets 编辑

Deprecated

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 compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

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

Syntax

Values

none
Does not apply any additional image rotation; the image is oriented as encoded or as other CSS property values dictate.
from-image
Default initial value. The EXIF information contained in the image is used to rotate the image appropriately.
<angle> This API has not been standardized.Obsolete since Gecko 63
The <angle> of rotation to apply to the image. It is rounded to the nearest 90deg (0.25turn).
flip This API has not been standardized.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.

Description

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.

Formal definition

Initial valuefrom-image
Applies toall elements
Inheritedyes
Computed valuean <angle>, rounded to the next quarter turn from 0deg and normalized, that is moduloing the value by 1turn
Animation typediscrete

Formal syntax

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

Examples

Orienting image from image data

CSS

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

HTML

<img id="image" src="https://mdn.mozillademos.org/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>

JavaScript

var imageOrientation = document.getElementById("imageOrientation");
imageOrientation.addEventListener("change", function (evt) {
  document.getElementById("image").style.imageOrientation = evt.target.value;
});

Result

Specifications

SpecificationStatusComment
CSS Images Module Level 3
The definition of 'image-orientation' in that specification.
Candidate RecommendationInitial definition.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:112 次

字数:10242

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文