Window: thuộc tính viewport
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The viewport read-only property of the Window interface returns a Viewport object instance, which provides information about the current state of the device's viewport.
See the Viewport API for all available properties.
Giá trị
A Viewport object instance.
Ví dụ
>Basic viewport usage
js
const currentViewport = window.viewport;
const segments = window.viewport.segments;
Đặc tả kỹ thuật
| Specification |
|---|
| CSS Viewport Module Level 1> # dom-window-viewport> |
Tính tương thích trên trình duyệt
Xem thêm
Viewport.segmentspropertyViewportinterfaceVisualViewportinterface- Viewport Segments API
- CSSOM view API
- Viewport concepts
- CSS viewport module
- CSSOM view module