zoukankan      html  css  js  c++  java
  • javascript 获取当前html 标签的位置

      var tt = document.getElementById(id);
            var ttop = tt.offsetTop;//绝对位置 left 的距离
            var thei = tt.clientHeight;
            var tleft = tt.offsetLeft;//绝对位置距离页面的 top 的高
            while (tt = tt.offsetParent) { ttop += tt.offsetTop; tleft += tt.offsetLeft; }

     var treebg=document.getElementById("test");

            treebg.style.top = ttop + thei + 6 + "px";//设置其他顶部的位置
            treebg.style.left = tleft - 5 + "px";//设置 左的位置

  • 相关阅读:
    HDU
    C# Stopwatch
    RMQ(Range Minimum Query)问题(转)
    HDU
    POJ
    HDU
    POJ
    POJ
    docker安装testlink
    廖雪峰Java2面向对象编程-3继承和多态-2多态
  • 原文地址:https://www.cnblogs.com/zxgl/p/2942980.html
Copyright © 2011-2022 走看看