cssjquery-ui

Custom style to jQuery UI dialogs


I am trying to change jQuery UI dialog's default styles to something similar to this -

enter image description here

I got it to close changing some CSS in jQuery UI.

.ui-widget {
    font-family: Verdana,Arial,sans-serif;
    font-size: .8em;
}

.ui-widget-content {
    background: #F9F9F9;
    border: 1px solid #90d93f;
    color: #222222;
}

.ui-dialog {
    left: 0;
    outline: 0 none;
    padding: 0 !important;
    position: absolute;
    top: 0;
}

#success {
    padding: 0;
    margin: 0; 
}

.ui-dialog .ui-dialog-content {
    background: none repeat scroll 0 0 transparent;
    border: 0 none;
    overflow: auto;
    position: relative;
    padding: 0 !important;
}

.ui-widget-header {
    background: #b0de78;
    border: 0;
    color: #fff;
    font-weight: normal;
}

.ui-dialog .ui-dialog-titlebar {
    padding: 0.1em .5em;
    position: relative;
        font-size: 1em;
}

HTML :

<div id="popup-msg">
    <div id="loading">
        <h2>Loading...</h2>
        <h3>Please wait a few seconds.</h3>
    </div>  
    
    <div id="success" title="Hurray,">
        <p>User table is updated.</p>
    </div>
</div>

THIS IS FIDDLE

But when I add this style its apply to all my dialogs. Can anybody tell me how can I avoid from this problem.

Thank you.


Solution

  • See https://jsfiddle.net/qP8DY/24/

    You can add a class (such as "success-dialog" in my example) to div#success, either directly in your HTML, or in your JavaScript by adding to the dialogClass option, as I've done.

    $('#success').dialog({
        height: 50,
        width: 350,
        modal: true,
        resizable: true,
        dialogClass: 'no-close success-dialog'
    });
    

    Then just add the success-dialog class to your CSS rules as appropriate. To indicate an element with two (or more) classes applied to it, just write them all together, with no spaces in between. For example:

    .ui-dialog.success-dialog {
        font-family: Verdana,Arial,sans-serif;
        font-size: .8em;
    }