Navigator:devicePosture 属性
Navigator.devicePosture 只读属性返回浏览器的 DevicePosture 对象,该对象允许开发者查询设备的当前姿态(即视口是否处于展开或折叠状态)并响应姿态变化来运行代码。
值
一个 DevicePosture 对象。
示例
js
const postureOutput = document.getElementById("currentPosture");
function reportPostureOutput() {
// type property returns "continuous" or "folded"
postureOutput.textContent = `Device posture: ${navigator.devicePosture.type}`;
}
navigator.devicePosture.addEventListener("change", reportPostureOutput);
规范
| 规范 |
|---|
| 设备姿态 API # dom-navigator-deviceposture |
浏览器兼容性
加载中…
另见
DevicePosturedevicePosture.type- 设备姿态 API
- CSS
device-posture@media特性