JqueryTools overlay position based on window size

和自甴很熟 提交于 2019-12-08 10:39:43

问题


I'm using JqueryTools overlay, running into a frustrating issue where the overlay only positions itself from the screen viewport instead of the HTML top edge. I haven't found any solutions so far. Can someone shed some light on to achieve this? Others are having the same issue. Are there alternatives to overlays? The reason I picked Jquery tools, I can use any background image and customize bunch of different things.

Here is the same issues listed on Jquery overlay forum.

"The problem seems to be that it positions itself relative to the screen viewport rather than the HTML page." - http://flowplayer.org/tools/forum/40/47781#post-47781

Any help/suggestion would be appreciated.


回答1:


I came looking for an answer to this, but the JQuery Tools forums seem to be down. This is how I solved it:

    $(window).resize(function() {
        var top = ($(window).height() / 2) - ($("#overlay").outerHeight() / 2);
        var left = ($(window).width() / 2) - ($("#overlay").outerWidth() / 2);
        $("#overlay").css("top", top);
        $("#overlay").css("left", left);
    });



回答2:


Solution can be found here: JqueryOverlay Tools Forum



来源:https://stackoverflow.com/questions/5575800/jquerytools-overlay-position-based-on-window-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!