zoukankan      html  css  js  c++  java
  • 有关元素元素位置的属性

    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,返回元素中的完整内容的宽度和高度(包括没有被显示出来的部分)。(注意:不是字面的滚动的宽度和高度

  • 相关阅读:
    雪花算法解决的问题
    ServiceStack6000次限制破解
    电商 详情页面 nginx 配置 优先请求静态页,若没有请求动态页,同时生成静态页
    docker 使用汇总
    .net 5 新特性 -- EFCoreDBFirst 介绍 和 .NET5 AOP 5个Filter
    模板方法设计模式:定义抽象类-模板:定义业务流程,执行步骤--》各业务类继承抽象类,实现各自不同 具体的执行步骤
    通过代理模式(包一层),实现对业务增加功能如日志,异常处理,缓存结果,到达不破坏原有的业务代码,扩展了功能
    设计模式
    mongodb 基本操作(增删改查),事务,数据失效机制
    log4net.Config
  • 原文地址:https://www.cnblogs.com/wangluochong/p/2442441.html
Copyright © 2011-2022 走看看