我遇到一个问题,即剑道窗口无法正确居中。
这是一个简单的小提琴,展示了这个问题。因此,在没有浏览器垂直滚动条的情况下,kendo窗口可以显示空间,但kendo窗口中心方法会将其置于中心位置,并强制浏览器滚动条显示。
小提琴: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();
});
请告诉我如何让kendo窗口正确居中。
答案 0 :(得分:7)
我认为问题已经解决了:)尝试。
$(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 强>