jQuery: Set modal dialog overlay color

前端 未结 5 624
萌比男神i
萌比男神i 2020-12-15 17:26

I would like to pop a modal dialog using jquery ui where the overlay is completely black. I know that I can set this in the theme, but I do not want all dialogs to have a bl

5条回答
  •  北海茫月
    2020-12-15 17:42

    You can use the open and close events of the ui-dialog.

    $("#your-dialog").dialog(
    {
        autoOpen: false, 
        modal: true, 
        open: function() {
            $('.ui-widget-overlay').addClass('custom-overlay');
        }          
    });
    

    And add the required styling in the CSS. Example:

    .ui-widget-overlay.custom-overlay
    {
        background-color: black;
        background-image: none;
        opacity: 0.9;
        z-index: 1040;    
    }
    

提交回复
热议问题