【问题标题】:Position of dialog box not in the center of the web browser对话框的位置不在网络浏览器的中心
【发布时间】:2015-05-01 00:48:17
【问题描述】:

我正在处理以下 php 和 java 脚本,一旦弹出 label_dialog 框,它就会打开到浏览器的左上角,即使我将它作为中心..任何人都可以帮助弄清楚为什么它不在中心?

php代码:-

            <div id="label_dialog" title="Submission Details">
              <center><table border='1' align="center">
              <div id="submission_details" name="submission_details"></div>
                </table></center>
            </div>

javascript代码:-

    $("#label_dialog").dialog({
        modal: true,
        draggable: false,
        resizable: true,
        position: ['center'],
        width: $( window ).width()*3/4,
        dialogClass: 'ui-dialog-osx',
        buttons: {
            "Edit": function() {
                $(this).dialog("close");
            },
            "Submit": function() {
                $(this).dialog("close");
                $('#submitted_gerrits_form').hide();
                $('#gerrits_form').hide();
                $("#component_form").hide();
                $("#submitted_gerrits_table").hide();
                $("#gerrits_form").hide();
                $("#check_gerrits").hide();
                $("#main_form_su_validation").hide();
                $("#contacts_form").hide();
                $("#dependencies_form").hide();
                $("#su_release_form").hide();
                $("#submission_note_form").hide();
                $("#submission").hide();

【问题讨论】:

    标签: javascript jquery html jquery-ui jquery-ui-dialog


    【解决方案1】:

    尝试删除该行:

    position: ['center'],
    

    如果您检查docs,您会发现您使用的格式不正确;职位必须是object。如果你想居中(这是默认设置),你会使用类似的东西:

    { my: "center", at: "center", of: window }
    

    不过,既然这是默认设置,您应该可以忽略它。

    【讨论】:

      【解决方案2】:

      我建议从您的代码中删除 &lt;center&gt;&lt;/center&gt; 并使用 css 或 style-"..."

      【讨论】:

      • 为什么?我从别人那里继承了这个代码,所以保持不变,如果更好的话我会改变,还有为什么&lt;div id="submission_details" name="submission_details"&gt;&lt;/div&gt;是什么意思?下面有没有像Mike这样的文档检查?
      • @user2125827 您必须更具体地了解“它是什么意思”。
      猜你喜欢
      • 2023-03-19
      • 2023-03-27
      • 1970-01-01
      • 2012-10-30
      • 1970-01-01
      • 2011-02-04
      • 2017-08-15
      • 2014-02-23
      • 2022-01-09
      相关资源
      最近更新 更多