有关元素元素位置的属性

web开发中,对页面元素的定位和控制对初学者来说一直是一个难点。下面是一些有关关于元素位置属性的理解。

offsetTop: 

        Retrieves the calculated top position of the object relative to the layout or coordinate parent, as specified by the offsetParent property

        返回对象元素边界的左上角顶点相对于上层HTML元素边界的左上角顶点的垂直位置。

offsetLeft:

        Retrieves the calculated left position of the object relative to the layout or coordinate parent, as specified by the offsetParent property

        返回对象元素边界的左上角顶点相对于上层HTML元素边界的左上角顶点的水平位置。

 

 

offsetWidth:

        Retrieves the width of the object relative to the layout or coordinate parent, as specified by the offsetParent property.

        返回对象自身的宽度

 

offsetHeight:

        Retrieves the height of the object relative to the layout or coordinate parent, as specified by the offsetParent property.

        返回对象自身的高度

 

ClientTop:

        Retrieves the distance between the offsetTop property and the true top of the client area

       

ClientLeft:

        Retrieves the distance between the offsetLeft property and the true left side of the client area.

       

        clientTop.clientLeft分别返回对象客户端的左上角顶点相对于自身边界的左上角顶点的垂直位置和水平位置。

        可以这样理解:HTML元素是一个容器区域,而这个在HTML元素中嵌入的内容将显示在容器区域的客户区域中。这有点类似房子的建筑面积(HTML元素的边界区域)和实际使用面积(HTML元素的客户端区域) 。

 

clientWidth:

        Retrieves the width of the object including padding, but not including margin, border, or scroll bar.

clientHeight:

        Retrieves the height of the object including padding, but not including margin, border, or scroll bar.

 

                clientWidth, clientHeight 返回对象上的可见客户端区的宽度和高度,不包括滚动条和边框部分。

 

 

scrollTop:

           Sets or retrieves the distance between the top of the object and the topmost portion of the content currently visible in the window.

        用于设置和返回元素上边界与当前被显示内容的上边界之间的距离。对于body对象而言,就是滚动条向下滑动的位置

scrollLeft:

        Sets or retrieves the distance between the left edge of the object and the leftmost portion of the content currently visible in the window.

        用于设置和返回元素左边界与当前被显示内容的左边界之间的距离。对于body对象而言,就是滚动条向右滑动的位置

 

 

scrollWidth:

           Retrieves the scrolling width of the object.

scrollHeight:

        Retrieves the scrolling height of the object.

       

        scrollWidth,scrollHeight,返回元素中的完整内容的宽度和高度(包括没有被显示出来的部分)。(注意:不是字面的滚动的宽度和高度

转载于:https://www.cnblogs.com/wangluochong/archive/2012/04/11/2442441.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值