How to overlay a div (or any element) over a table row (tr)?

后端 未结 6 1057
轮回少年
轮回少年 2021-01-30 12:58

I\'d like to overlay a div (or any element that\'ll work) over a table row (tr tag) that happens to have more than one column.

I have tried a few methods, which don\'t s

6条回答
  •  粉色の甜心
    2021-01-30 13:24

    Getting the height and width of an object straightforward. The hard part for me was the Top and Left coordinates for absolute positioning.

    This is the only script that has ever worked reliably for me:

    function posY(ctl)
    {
        var pos = ctl.offsetHeight;
        while(ctl != null){
            pos += ctl.offsetTop;
    
            ctl = ctl.offsetParent; 
        }
    
        return pos;
    }
    function posX(ctl)
    {
        var pos = 0;
        while(ctl != null){
            pos += ctl.offsetLeft;
    
            ctl = ctl.offsetParent; 
        }
    
        return pos;
    
    }
    

提交回复
热议问题