Проблемы со стилем и размерами диалогового окна jQuery UI - PullRequest
0 голосов
/ 10 июня 2018

Я делаю диалог jQuery UI.Он выглядит идеально, и мой стиль работает, но первый элемент абзаца в диалоге массивный.

Screenshot of large paragraph

CSS не устанавливает ничего, кромешрифт.Если я добавлю max-height: 1.5em;, то все они накапливаются друг на друге, как показано ниже.

Element

Понятия не имею, что делает это, номой код ниже.У меня такое ощущение, что это происходит из-за содержимого в другом месте страницы, заставляющего элемент двигаться.

    #cadEditor {
      display: none;
      z-index: 999999 !important;
      background: #222;
    }

    .ui-dialog {
      background: #222;
    }

    .ui-dialog .ui-dialog-titlebar {
      background: #333;
      height: 40px;
      top: 0;
      text-align: center;
      line-height: 40px;
    }

    .ui-dialog .ui-dialog-title {
      position: absolute;
      top: 0;
      display: block;
      width: 100%;
      height: fit-content;
      text-align: center;
    }

    #cadEditor p {
      max-height: 1.5em;
    }

    .ui-dialog .ui-dialog-titlebar-close {
      display: none;
    }

    .ui-dialog .ui-button {
      color: #fff;
      background: #222;
      padding: 0.3em 0.5em;
      border: #000000 1px solid;
      border-radius: 5px;
      margin: 1em;
      cursor: pointer;
    }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<div id="cadEditor">
    <p>Test Dialog</p>
    <p>Test Dialog</p>
    <p>Test Dialog</p>
    <p>Test Dialog</p>
    <p>Test Dialog</p>
    <p>Test Dialog</p>
    <p>Test Dialog</p>
    <p>Test Dialog</p>
    <p>Test Dialog</p>
    <p>Test Dialog</p>
</div>
<script>
    function showCadEditor(button) {
        $('#cadEditor').dialog({
            dialogClass: "cadEditorDialog",
            autoOpen: true,
            title: "Editing Cad " + $(button).attr("forcad"),
            modal: true,
            resizable: false,
            width: 600,
             buttons: {
                "Save": function () {
                    $(this).dialog("close");
                },
                "Cancel": function () {
                    $(this).dialog("close");
                }
            }
        });

        return false;
    }

    showCadEditor();
</script>

Ответы [ 2 ]

0 голосов
/ 10 июня 2018

Я исправил проблему с помощью position: absolute; в содержимом диалога (#cadEditor).

0 голосов
/ 10 июня 2018

Я только что скопировал ваш вопрос в HTML.Выглядит хорошо для меня.Можете ли вы объяснить свой вопрос более подробно?Может быть стиль сайта перезаписывает стили всплывающего окна.

<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>Title Goes Here</title> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<style>
    #cadEditor {
      display: none;
      z-index: 999999 !important;
      background: #222;
    }

    .ui-dialog {
      background: #222;
    }

    .ui-dialog .ui-dialog-titlebar {
      background: #333;
      height: 40px;
      top: 0;
      text-align: center;
      line-height: 40px;
    }

    .ui-dialog .ui-dialog-title {
      position: absolute;
      top: 0;
      display: block;
      width: 100%;
      height: fit-content;
      text-align: center;
    }

    #cadEditor p {
      max-height: 1.5em;
    }

    .ui-dialog .ui-dialog-titlebar-close {
      display: none;
    }
    
    body{color: white}
</style>
</head>
    <body> <p>This is my web page</p>
    <div id="cadEditor">
        <p>Test Dialog</p>
        <p>Test Dialog</p>
        <p>Test Dialog</p>
        <p>Test Dialog</p>
        <p>Test Dialog</p>
        <p>Test Dialog</p>
        <p>Test Dialog</p>
        <p>Test Dialog</p>
        <p>Test Dialog</p>
        <p>Test Dialog</p>
    </div>
    <script>
        function showCadEditor(button) {
            $('#cadEditor').dialog({
                dialogClass: "cadEditorDialog",
                autoOpen: true,
                title: "Editing Cad " + $(button).attr("forcad"),
                modal: true,
                resizable: false,
                width: 600,
                 buttons: {
                    "Save": function () {
                        $(this).dialog("close");
                    },
                    "Cancel": function () {
                        $(this).dialog("close");
                    }
                }
            });

            return false;
        }

        showCadEditor();
    </script>    
</body>
</html>

enter image description here

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...