繁体   English   中英

如何在屏幕中央显示模态弹出窗口,以及如何在调整屏幕大小时保持位置

[英]how to show an modal pop up in the center of screen and maintain the position on resizing the screen also

我有一个模态弹出窗口,我正在使用javascript在屏幕中间显示它

$('div.openIDPopup').css({ 'height': $(document).height() + 'px',
        'width': $(window).width() + 'px',
        'visibility': 'visible'
    })
        .fadeIn('slow');
    $('div.openId').css({ 'visibility': 'visible',
        'top': ($(window).height() / 4) + 'px',
        'left': ($(window).width() / 3) + 'px'
    })
    .fadeIn('slow');

但在调整屏幕大小时,它会停留在该位置,因为它已完全确定了如何获得该功能。

您可能想看看这个基于CSS的解决方案: http : //www.wpdfd.com/editorial/thebox/deadcentre4.html

它依赖于使用负边距,我认为效果很好。

参见此处了解其操作方法: http//www.sohtanaka.com/web-design/examples/modal-window/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM