orientation CSS descriptor controls the orientation of a document defined by @viewport .

/* Keyword values */
orientation: auto;
orientation: portrait;
orientation: landscape;
					

For a UA/device where the orientation is changed upon tilting the device, an author can use this descriptor to inhibit the orientation change.

句法

auto

The user agent will set the document's orientation automatically, typically based on the device's orientation as determined by an accelerometer (if the device has such a hardware sensor), although there is often a user-controlled, OS-level "Lock orientation" setting that will trump the accelerometer reading.

portrait

The document should be locked into portrait orientation.

landscape

The document should be locked into landscape orientation.

形式定义

相关 at-rule @viewport
初始值 auto
百分比 refer to the size of bounding box
计算值 如指定

形式句法

auto | portrait | landscape
					

范例

Setting viewport orientation

@viewport {
  orientation: landscape;
}
					

规范

规范 状态 注释
CSS Device Adaptation
The definition of '"orientation" 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
orientation descriptor Chrome 不支持 No Edge 不支持 12 — 79 Prefixed
不支持 12 — 79 Prefixed
Prefixed Implemented with the vendor prefix: -ms-
Firefox 不支持 No IE 完整支持 10 Prefixed
完整支持 10 Prefixed
Prefixed Implemented with the vendor prefix: -ms-
Opera 不支持 No Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android 不支持 11.1 — 14 Prefixed
不支持 11.1 — 14 Prefixed
Prefixed Implemented with the vendor prefix: -o-
Safari iOS 不支持 No Samsung Internet Android 不支持 No

图例

完整支持

完整支持

不支持

不支持

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

另请参阅

元数据

  • 最后修改:
  1. CSS
  2. CSS 参考
  3. CSS Device Adaptation
  4. At-Rules
    1. @viewport

Copyright  © 2014-2026 乐数软件    

工业和信息化部: 粤ICP备14079481号-1