这篇翻译不完整。请帮忙从英语翻译这篇文章

The @viewport CSS at-rule lets you configure the viewport through which the document is viewed. It's primarily used for mobile devices, but is also used by desktop browsers that support features like "snap to edge" (such as Microsoft Edge).

Lengths specified as percentages are calculated relative to the initial viewport, which is the viewport before any user agent or authored styles have had an opportunity to adjust the viewport. This is typically based on the size of the window on desktop browsers that aren't in full screen mode.

On mobile devices (or desktop devices that are in full screen mode), the initial viewport is usually the portion of a device's screen that is available for application use. This may be either the full screen or the full screen area minus areas controlled by the operating system (such as a taskbar) or the application-available screen area (either the full screen or the screen minus any areas owned by the operating system or other applications).

@viewport {
  width: device-width;
}

语法

The at-rule contains a set of nested descriptors in a CSS block that is delimited by curly braces.

A zoom factor of 1.0 or 100% corresponds to no zooming. Larger values zoom in. Smaller values zoom out.

描述符

Browser support for @viewport is weak at this time, with support being largely available in Internet Explorer and Edge. Even in those browsers, only a small number of descriptors are available. Browsers will ignore @viewport if they don't support it, and will ignore any descriptors that they don't recognize.

min-width
设置viewport的最小宽度
max-width
设置viewport的最大宽度
width
同时设置 min-widthmax-width
min-height
设置viewport的最小高度
max-height
设置viewport的最大高度
height
同时设置 min-heightmax-height
zoom
设置初始缩放系数
min-zoom
设置最小缩放系数
max-zoom
设置最大缩放系数
user-zoom
设置用户是能更改缩放系数
orientation
Controls the document's orientation.
viewport-fit
Controls the display of the document on non-rectangular displays.

Formal syntax

@viewport {
  <group-rule-body>
}

Examples

@viewport {
  min-width: 640px;
  max-width: 800px;
}

@viewport {
  zoom: 0.75;
  min-zoom: 0.5;
  max-zoom: 0.9;
}

@viewport {
  orientation: landscape;
}

Specifications

Specification Status Comment
CSS Round Display Level 1
@viewport
Working Draft Defined the viewport-fit descriptor.
CSS Device Adaptation
@viewport
Working Draft Initial definition

Browser compatibility

FeatureChromeEdgeFirefoxInternet ExplorerOperaSafari
Basic support291 2 Yes -ms- 3 No410 -ms-

165

11.1 — 15 -o-

No6
height descriptor29 ? No10 -ms-

16

11.1 — 15

No
max-height descriptor29 ? No10 -ms-

16

11.1 — 15

No
max-width descriptor29 ? No10 -ms-

16

11.1 — 15

No
max-zoom descriptor29 Yes -ms- No10 -ms- ? No
min-height descriptor29 ? No10 -ms-

16

11.1 — 15

No
min-width descriptor29 ? No10 -ms-

16

11.1 — 15

No
min-zoom descriptor29 Yes -ms- No10 -ms- ? No
orientation descriptor No ? No10 -ms- No ?
user-zoom descriptor29 Yes -ms- No10 -ms- ? No
viewport-fit descriptor ? ? ? ? ?11
width descriptor29 ? No10 -ms-

16

11.1 — 15

No
zoom descriptor29 ? No10 -ms- 16 No
FeatureAndroid webviewChrome for AndroidEdge mobileFirefox for AndroidOpera AndroidiOS SafariSamsung Internet
Basic support4.429 Yes -ms- 3 No4 ? No6 Yes
height descriptor4.429 ? No

16

11.1 — 14

No Yes
max-height descriptor4.429 ? No

16

11.1 — 14

No Yes
max-width descriptor4.429 ? No

16

11.1 — 14

No Yes
max-zoom descriptor ?29 Yes -ms- No ? No ?
min-height descriptor4.429 ? No

16

11.1 — 14

No Yes
min-width descriptor4.429 ? No ? No Yes
min-zoom descriptor ?29 Yes -ms- No ? No ?
orientation descriptor ? ? ? ?8 -o- ? No
user-zoom descriptor ?29 Yes -ms- No ? No ?
viewport-fit descriptor ? ? ? ? ?11 ?
width descriptor4.429 ? No

16

11.1 — 14

No Yes
zoom descriptor4.461 ? No37 ? No

1. See Chromium bug 235457.

2. From version 29: this feature is behind the --enable-experimental-webkit-features runtime flag and the --enable-viewport runtime flag.

3. This feature is behind the Enable @-ms-viewport rules preference.

4. See Firefox bug 747754.

5. From version 16: this feature is behind the --enable-experimental-webkit-features runtime flag and the --enable-viewport runtime flag.

6. See WebKit bug 95959.

See also

文档标签和贡献者

此页面的贡献者: DKLost, cvrebert
最后编辑者: DKLost,