大网数据广告活动
Web 标准与前端开发

`image-resolution` CSS property

· 52CE 我爱测

The **`image-resolution`** CSS property specifies the intrinsic resolution of all raster images used in or on the element. It affects content images such as replaced elements and generated content, and decorative images such as `background-image` images.

The image-resolution CSS property specifies the intrinsic resolution of all raster images used in or on the element. It affects content images such as replaced elements and generated content, and decorative images such as background-image images.

The image resolution is defined as the number of image pixels per unit length, e.g., pixels per inch. By default, CSS assumes a resolution of one image pixel per CSS px unit; however, the image-resolution property allows a different resolution to be specified.

Syntax

image-resolution: from-image;
image-resolution: 300dpi;
image-resolution: from-image 300dpi;
image-resolution: 300dpi snap;

/* Global values */
image-resolution: inherit;
image-resolution: initial;
image-resolution: revert;
image-resolution: revert-layer;
image-resolution: unset;

Values

This property is specified as one or more space-separated values from the following list:

  • resolution
    • : Specifies the intrinsic resolution explicitly.
  • from-image
    • : Uses the intrinsic resolution as specified by the image format. If the image does not specify its own resolution, the explicitly specified resolution is used (if given), else it defaults to 1dppx (1 image pixel per CSS px unit).
  • snap
    • : If the snap keyword is provided, the computed resolution is the specified resolution rounded to the nearest value that would map one image pixel to an integer number of device pixel. If the resolution is taken from the image, then the used intrinsic resolution is the image's native resolution similarly adjusted.

[!NOTE] As vector formats such as SVG do not have an intrinsic resolution, this property has no effect on vector images.

Formal definition

Formal syntax

Examples

Setting a high dpi for print

When printing the document, use a higher resolution.

@media print {
  .my-image {
    image-resolution: 300dpi;
  }
}

Use image resolution with fallback

Uses the resolution from the image. If the image does not have a resolution, use 300dpi rather than the default 1dppx.

.my-image {
  image-resolution: from-image 300dpi;
}

Specifications

Browser compatibility

Currently, no browsers support this feature.

See also

  • Other image-related CSS properties: object-fit, object-position, image-orientation, image-rendering.
  • Chromium bug: 1086473.

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。