C# jquery对话框未居中

C# jquery对话框未居中,c#,jquery,dialog,C#,Jquery,Dialog,编辑:将其重写为仅html 在下面的代码中,为什么显示的jquery对话框不居中?单击页面上的“测试”按钮打开对话框 <html> <head> <script type="text/javascript" src="jquery-1.4.2.min.js"></script> <script type="text/javascript" src="ui/jquery.ui.core.js"></script>

编辑:将其重写为仅html

在下面的代码中,为什么显示的jquery对话框不居中?单击页面上的“测试”按钮打开对话框

<html>
<head>
    <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="ui/jquery.ui.core.js"></script>
    <script type="text/javascript" src="ui/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="ui/jquery.ui.dialog.js"></script>
    <link type="text/css" href="themes/base/jquery.ui.all.css" rel="stylesheet" />

<script>
  function showDialog() {
    $("#dialog-modal").dialog({
        resizable: true,
        height: 140,
        modal: true,
        position: 'center',
        buttons: {
            'Yes': function () {
                $(this).dialog("close");
                return true;
            },
            'No': function () {
                $(this).dialog("close");
                return false;
            }
        }
    });
  }
</script>

</head>
<body>

<div style="width:800px; height:800px; border:solid 1px red;">

<div id="dialog-modal" title="Basic dialog"></div>

<input type="button" value="test" onclick="showDialog();"></input>

</div><!-- End demo -->


</body>

</html>

函数showDialog(){
$(“#对话框模式”).dialog({
可调整大小:正确,
身高:140,
莫代尔:是的,
位置:'中间',
按钮:{
“是”:函数(){
$(此).dialog(“关闭”);
返回true;
},
“否”:函数(){
$(此).dialog(“关闭”);
返回false;
}
}
});
}

我已在上重新创建了您的场景。我已经测试过几次了,我无法复制你所说的。你能再检查一下吗?您能确认我们您没有使用任何额外的CSS吗

注意:我做了一些小的(非关键性的)更改以使其正常工作


希望有帮助。

我通过添加以下内容解决了此问题:

<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/jquery-ui.min.js"
    type="text/javascript"></script>
<script src="http://jquery-ui.googlecode.com/svn/tags/latest/external/jquery.bgiframe-2.1.1.js"
    type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.3/i18n/jquery-ui-i18n.min.js"
    type="text/javascript"></script>


为什么不在创建对话框时设置
位置
选项?@Matt Ball-我尝试过,它没有改变任何东西。我以前在定位jQueryUI对话框时肯定遇到过一些问题。有没有可能你可以发布一个复制链接(在jsbin或类似的网站上)?@dcp-尝试将
“displayOkAlert();”
更改为
”$(displayOkAlert);“
,有什么效果吗?@Nick Craver-谢谢,但没有效果。这是因为包含了jquery的js文件。您真的需要单独尝试(即在像JSFIDLE这样的站点之外),这样我就可以看到包含了哪些文件。JQuery似乎对此非常挑剔。