CSSOM view API
CSSOM 视图 API 允许你操作文档的视觉呈现,包括获取元素布局框的位置,通过脚本获取视口宽度或高度,以及滚动元素。
指南
- 坐标系
- : 坐标系常用于指定显示上下文中位置,例如显示器的窗口、移动设备上的视口,或打印时纸张上的位置。
- 视口概念
- : 视口的概念——什么是视口,视口在 CSS、SVG 和移动设备中的影响,以及可视视口与布局视口之间的区别。
接口
- MediaQueryList
- MediaQueryListEvent
- Screen
- CaretPosition
- VisualViewport
对其他接口的扩展
此模块为其他规范中定义的接口添加了属性、方法和事件。
扩展 Window
- Window.devicePixelRatio
- Window.innerHeight
- Window.innerWidth
- Window.matchMedia
- Window.moveBy
- Window.moveTo
- Window.outerHeight
- Window.outerWidth
pageXOffset(查看 Window.scrollX)pageYOffset(查看 Window.scrollY)- Window.resizeBy
- Window.resizeTo
- Window.screen
- Window.screenLeft
- Window.screenTop
- Window.screenX
- Window.screenY
- Window.visualViewport
- Window.scroll
- Window.scrollBy
- Window.scrollTo
- Window.scrollX
- Window.scrollY
- Window/resize_event 事件
扩展 Document
- Document.elementFromPoint
- Document.caretPositionFromPoint
- Document.scrollingElement
- Document/scroll_event 事件
- Document/scrollend_event 事件
扩展 Element
- Element.checkVisibility
- Element.clientHeight
- Element.clientLeft
- Element.clientTop
- Element.clientWidth
- Element.currentCSSZoom
- Element.getBoundingClientRect
- Element.getClientRects
- Element.scroll
- Element.scrollBy
- Element.scrollHeight
- Element.scrollIntoView
- Element.scrollLeft
- Element.scrollTo
- Element.scrollTop
- Element.scrollWidth
- Element/scroll_event 事件
- Element/scrollend_event 事件
扩展 HTMLElement
- HTMLElement.offsetHeight
- HTMLElement.offsetLeft
- HTMLElement.offsetParent
- HTMLElement.offsetTop
- HTMLElement.offsetWidth
扩展 HTMLImageElement
- HTMLImageElement.x
- HTMLImageElement.y
扩展 Range
- Range.getBoundingClientRect
- Range.getClientRects
扩展 MouseEvent
- MouseEvent.clientX
- MouseEvent.clientY
- MouseEvent.offsetX
- MouseEvent.offsetY
- MouseEvent.pageX
- MouseEvent.pageY
- MouseEvent.screenY
- MouseEvent.x
- MouseEvent.y
本模块定义了适用于 Text、Element、CSSPseudoElement、Document 接口的几何辅助方法。这些 GeometryUtils 功能目前尚未在任何浏览器中实现。
规范
参见
- CSS 对象模型(CSSOM) API
- CSS 对象模型视图模块
- CSS 溢出模块
- CSS 滚动行为模块
- CSS 滚动吸附模块
- Viewport
- Layout viewport
- Visual viewport
- zoom
- CSSOM
- CSS pixel
- Scroll container
- meta
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
