CSS: overflow-y: scroll; overflow-x: visible

前端 未结 2 1526
半阙折子戏
半阙折子戏 2021-02-19 02:24

See the following post for a picture highlighting my question and a potential solution:

CSS overflow-y:visible, overflow-x:scroll

However, this strategy breaks w

2条回答
  •  隐瞒了意图╮
    2021-02-19 02:43

    I ended up implementing this using javascript, using the getPos function from this question.

    The end product looks like:

    var scrollPanel = ...;
    var tooltip = ...;
    function nodeHovered(e) {
       var hovered = e.srcElement;
       var pos = getPos(hovered);
       pos.x += hovered.offsetWidth;
       pos.y -= scrollPanel.scrollTop;
       tooltip.style.setProperty('left', pos.x);
       tooltip.style.setProperty('top', pos.y);
    }
    

    Basically, I calculate where on the page the node is currently displayed (taking into account the scrollbar position), and manually place the tooltip in the right spot on the page.

    Too bad there's no elegant/CSS way to do this, but at least this works.

提交回复
热议问题