【问题标题】:jQuery: SimpleModal Autoresize to window sizejQuery:SimpleModal 自动调整为窗口大小
【发布时间】:2013-03-05 19:56:56
【问题描述】:

我在 CSS 中将 SimpleModal 设置为屏幕大小的 80%:

#simplemodal-container {
    background-color: white;
    border: 4px solid #aaaaaa;
    padding: 12px;
    height: 80%;
    width: 80%;
}

我希望 SimpoleModel 在用户更改窗口大小时根据窗口大小调整大小。

这不起作用:

   $(function () {
        $('#agreement-modal-content').modal(
            {
                autoResize: true,
            }
        );
    });

【问题讨论】:

    标签: jquery jquery-ui simplemodal


    【解决方案1】:

    这是对我有用的解决方案:

      $(function() {
            $('#agreement-modal-content').modal(
                {
                    autoResize: false,
                    onShow: function(dialog) {
                        var h = $(window).height();
                        var w = $(window).width();
                        dialog.container.css('height', '80%');
                        dialog.container.css('width', '80%');
                        var h2 = dialog.container.height();
                        var w2 = dialog.container.width();
                        var top = (h / 2) - (h2 / 2) - h2;
                        var left = (w / 2) - (w2 / 2) - w2;
    
                        if (top < 60) {
                            top = 60;
                        }
    
                        if (left < 60) {
                            left = 60;
                        }
    
                       dialog.container.css('left', left + 'px');
                       dialog.container.css('top', top + 'px');
    
                    }
                }
            );
          }
        );
    

    【讨论】:

    • 质量解决方案,仅供可能看到此内容的人参考,根据您的设置,您需要调整他的常量。 (我使用左作为 %,宽度使用 85%)
    猜你喜欢
    • 2017-03-12
    • 1970-01-01
    • 1970-01-01
    • 2011-12-21
    • 2017-04-29
    • 2011-02-28
    • 2019-07-03
    • 2011-06-17
    • 2012-03-16
    相关资源
    最近更新 更多