3

我有一个问题是剑道窗口没有正确居中。

这是一个演示该问题的简单小提琴。所以剑道窗口在没有浏览器垂直滚动条的情况下有显示的空间,但是剑道窗口中心方法,将其置于中心位置,并强制浏览器滚动条出现。

在此处输入图像描述

小提琴:http: //jsfiddle.net/codeowl/QKPN6/2/

HTML:

<div id="testWindow">
    <p>here is the test content here is the test content</p>
    <p>here is the test content here is the test content</p>
    <p>here is the test content here is the test content</p>
    <p>here is the test content here is the test content</p>
    <p>here is the test content here is the test content</p>
    <p>here is the test content here is the test content</p>
    <p>here is the test content here is the test content</p>
    <p>here is the test content here is the test content</p>
    <p>here is the test content here is the test content</p>
    <p>here is the test content here is the test content</p>
    <p>here is the test content here is the test content</p>
    <p>here is the test content here is the test content</p>
    <p>here is the test content here is the test content</p>
</div>

JavaScript:

$(document).ready(function() {
    var oWin = null;
    $('#testWindow').kendoWindow();
    oWin = $('#testWindow').data('kendoWindow');
    oWin.center();
});

请告诉我如何让剑道窗口正确居中。

4

1 回答 1

8

我认为问题解决了:) 试试看。

$(document).ready(function() {
    var oWin = null;
    var h = window.innerHeight;
    $('#testWindow').kendoWindow({});
    oWin = $('#testWindow').data('kendoWindow');
    oWin.center().open();
    $('#testWindow').closest(".k-window").css({
        top: h/2 - $('#testWindow').parent()[0].scrollHeight/2
    });
});

JSFiddle

于 2014-05-20T12:53:29.553 回答