zoukankan      html  css  js  c++  java
  • 获取元素 在浏览器窗口中的 坐标

    嗯哼。不多说,直接上代码了。

    • // 获取元素 在 浏览器窗口 中的 坐标     Test Already.
      function posInClient(obj){
          var theClient = obj.getBoundingClientRect();    // 获取元素的左,上,右和下分别相对 浏览器视窗 的位置
          
          // 在IE中,默认坐标从(2,2)开始计算,导致最终距离比其他浏览器多出两个像素,需要做以下兼容
          var top2px = document.documentElement.clientTop;
          var left2px = document.documentElement.clientLeft;
          
          return {
              top: theClient.top - top2px,
              left: theClient.left - left2px,
              
              bottom: theClient.bottom + top2px,
              right: theClient.right + left2px
          };
      }
    --------小尾巴 ________一个人欣赏-最后一朵颜色的消逝-忠诚于我的是·一颗叫做野的心.决不受人奴役.怒火中生的那一刻·终将结束...
  • 相关阅读:
    Codeforces 1182E Product Oriented Recurrence 矩阵快速幂
    Codeforces 1182D Complete Mirror hash
    HDU
    HDU
    HDU
    HDU
    HDU
    HDU
    web框架之Vue渐进式框架-安装及入门
    web框架之Jqeury基本使用
  • 原文地址:https://www.cnblogs.com/tianxiaxuange/p/9873916.html
Copyright © 2011-2022 走看看