Skip to main content

HTMLElement.style

HTMLElement.style 属性返回一个 CSSStyleDeclaration 对象,表示元素的 内联 style 属性(attribute),但无法读取内嵌和外部的样式表属性。

Window.getComputedStyle()

可以获取内联、内嵌还是外部样式表所有的 css 样式

Element.getBoundingClientRect()

用于获取某个元素相对于视窗的位置集合。返回的对象中有 top, right, bottom, left,width,height 等属性。除了 width 和 height 外的属性都是相对于视口的左上角位置而言的。

参考