这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

viewport-fit CSS @viewport descriptor controls how a document's viewport fills the screen.

句法

/* Keyword values */
viewport-fit: auto;
viewport-fit: contain;
viewport-fit: cover;
					

auto

This value doesn’t affect the initial layout viewport, and the whole web page is viewable.

contain

The viewport is scaled to fit the largest rectangle inscribed within the display.

cover
The viewport is scaled to fill the device display. It is highly recommended to make use of the safe area inset variables to ensure that important content doesn't end up outside the display.
This descriptor hasn't been added to https://github.com/mdn/data/blob/master/css/at-rules.json yet.

可访问性关注

当使用 viewport-fit descriptor, one must keep in mind that not all device displays are rectangular, and should therefore make use of the safe area inset variables .

形式定义

相关 at-rule @viewport
初始值 auto
计算值 如指定

形式句法

auto | contain | cover
					

范例

Scaling viewport to fit device display

@viewport {
  viewport-fit: cover;
}
					

规范

规范 状态 注释
CSS Round Display Level 1
The definition of '"viewport-fit" descriptor' in that specification.
工作草案 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
viewport-fit descriptor Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 不支持 No

图例

不支持

不支持

另请参阅

元数据

  • 最后修改: