Problems with the appearance and dimensions of jQuery UI dialog boxes

My jQuery UI Dialog is displaying correctly with all the styling applied, but I am facing an issue where the first paragraph element appears overly large in the dialog box.

https://i.sstatic.net/0HfUb.png

Despite setting only the font in the CSS, adding max-height: 1.5em; causes the paragraphs to stack on top of each other as shown below.

https://i.sstatic.net/T4Whk.gif

I am unsure of what is causing this issue. Below is my code, and I suspect that it might be related to the content elsewhere on the page affecting the element's position.

    #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>

Answer №1

I just transferred your question to HTML format. It appears fine to me. Could you provide more details explaining your question? It's possible that the website's style is overriding the styles of the popup.

<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>

https://i.sstatic.net/8T9aD.png

Answer №2

The problem was resolved when I applied the position: absolute; to the dialog content element (#cadEditor).

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

A checkbox nestled within a span is clicked to trigger an event that validates the input, presenting a complex

This particular piece of code is causing a recursive behavior. I am looking for a way to enable clicking on the text within the span element to toggle the checked/unchecked state of the child input and then trigger the click event for the child input. Ch ...

Sidenav Content with all elements having opacity applied

How can I ensure that all page elements have a black background color when the mobile navigation is opened on the left screen, while ensuring that my sidebar and content image do not get overlaid by the black background? Here is my code: function openNav( ...

Ways to customize the appearance of Angular material elements one by one?

I have a component that contains two Angular Material form components: <!-- First input --> <mat-form-field> <mat-label>Password</mat-label> <input matInput type="text"> </mat-form-field> <br&g ...

Prevent the Bootstrap Navbar from collapsing

Trying to customize a Bootstrap navbar for specific needs, I've encountered an issue. I want the first two links on the left (home and menu glyphs) to remain visible even when the window is resized down, while the rest should collapse. Check out the ...

Using jQuery to add a new column to a table and populate it with values from the preceding

I recently started learning jQuery and stumbled upon this website, which has been more helpful than other resources. I'm currently facing an issue with adding a column to a table. The new column should contain the value from the previous column. Here ...

Consistently Incorrect Date Formatting in Bootstrap Display

I have a potential issue with my date display. It should show a default "Start Date" in a short date format, but when the "Sale Date" DropDownBoxFor is toggled, it should display an AJAX result date. However, the display always appears in a date and time f ...

What is the best way to include basic static files and HTML together in a NodeJS environment?

I am facing an issue trying to serve an HTML file with its CSS and JS files in NodeJS using express.static(), but unfortunately, it is not working as expected. I have followed the steps shown in several tutorials, but for some reason, the output is not co ...

What could be causing the vertical centering issue with my text inside a bootstrap row div?

I have a Bootstrap row and I'm attempting to center some text vertically, but it's only centered horizontally. Current Layout: https://i.sstatic.net/XcqHi.png Desired Layout: https://i.sstatic.net/ZegKG.png The second image shows the phrase "c ...

Is there a way to identify the specific table row <tr> where the keyup event is triggered?

I am facing an issue with editing a long table on the screen. The table has 10,000 rows and 10 columns and I want to be able to save changes made to individual rows without having to save the entire table each time. Each row has a unique id along with the ...

Currently experiencing difficulty with arrow key navigation in ReactJS

I'm attempting to create a xmb (psp/ps3) menu using react, but I've encountered an issue. The problem is that the items scroll past each other instead of moving in order. For example: Item 1 jumps to Item 3 (skipping Item 2, even though it should ...

The page is present, but unfortunately, the content is displaying a 404 error. I am considering using Selenium to retrieve

Is there a way to use Selenium webdriver to download images from a dynamically updated website, like this site? Every day a new page is created with images uploaded around 6 pm. How can I retrieve these images using Python and Selenium? url = 'http:/ ...

retrieving data in an array using an ajax request

Having trouble extracting two values from an ajax call. I can't seem to separate the results returned from the call. $.ajax({ type:'POST', url: 'inc/getuser.php?q='+boxnum, success:functi ...

Tips for aligning a Bootstrap container in the middle of the viewport vertically

I'm struggling to center a Bootstrap container vertically in the viewport. You can view my code at http://www.bootply.com/C8vhHTifcE All of my attempts at centering have been unsuccessful. Does anyone have a solution? Just to clarify: I want the co ...

Optimal approach for creating a CSS button with a dynamic size, gradient background and arrow design

I'm utilizing the Zurb Foundation framework and aiming to create dynamic call-to-action buttons with varying sizes, text, a background gradient, and a right-pointing arrow. There are three potential approaches I've envisioned: Employ an a el ...

Issue: jQuery 1.9 causing freezing in Internet Explorer 9 following initial $ajax request

When creating a dynamic webpage, I encountered an issue with Internet Explorer hanging after the first request when using Ajax Long Polling with jQuery 1.9. The script code I implemented is based on this article: Simple Long Polling Example with JavaScrip ...

The Cycle2 pager feature eliminates the ability to control Youtube video playback

I am currently utilizing the Cycle2 slideshow plugin (http://jquery.malsup.com/cycle2/) to showcase images on my website. However, I've encountered an issue where the CSS from Cycle2 interferes with the controls of YouTube videos when displayed togeth ...

Arrange the HTML elements in a line, one following the next

I need assistance with aligning two dropdown lists in the jsbin provided. How can I position them one after the other, center them on the page, and ensure there is enough space between the two elements without manually adding spaces using   In additi ...

Horizontal compression applied to background image

After following a suggestion ("css only technique number 1" found here http://css-tricks.com/perfect-full-page-background-image/), I experimented with using an inline img element and CSS to create a background image that would occupy the entire browser win ...

Creating a central navigation menu for a website

Currently, I am working on incorporating a menu in the center of a webpage (please note that this is not a top navigation menu). Here is the initial setup: https://i.sstatic.net/3arql.png Users are able to click on various menu items to access different ...

Generating an HTML table using a JavaScript object dynamically

I am in the process of dynamically generating an HTML table using information from a MySQL database table. The data within the table is regularly changing, requiring the HTML table to be updated accordingly when alterations are made to the database table. ...