zoukankan      html  css  js  c++  java
  • 获取dom top left width heigth方法

    export const getOffset = $target => {
        if(!$target) return false;
        /**
         * getBoundingClientRect是获取元素相对于视口的坐标信息的方法
         * window.pageXOffset 获取文档当前上下卷起的高度
         * window.pageXOffset 获取文档当前左右卷起的高度
         */
        const obj = $target.getBoundingClientRect()
        return {
          left: obj.left + window.pageXOffset,
          top: obj.top + window.pageYOffset,
           Math.round(obj.width),
          height: Math.round(obj.height)
        }
        
    }
  • 相关阅读:
    Linux
    Cookie & Session
    HTTP
    HTTP
    抓包工具
    抓包工具
    抓包工具
    python
    python
    python
  • 原文地址:https://www.cnblogs.com/hellolol/p/11555194.html
Copyright © 2011-2022 走看看