用法:
object.getBoundingClientRect( ) 返回一个对象。
DOMRect 对象包含了一组用于描述边框的只读属性——left、top、right和bottom,单位为像素。
- rect() 返回的 width 和 height 包括元素的边框。 rect ().width=width+border*2 , rect ().height=height+border*2
- 除了 width 和 height 外的属性都是相对于视口的左上角位置而言的。
例子说明
1. 用 document.documentElement 返回网页的根节点(<html>)
2. 执行 object.getBoundingClientRect( ) 会得到元素的 top、right、bottom、left、width、height 属性,这些属性以一个对象的方式返回。
<html>
<head>
<style>
:checked{
color:red}
</style>
&l