對話框標記(覆蓋陰影,邊框,背景,標題欄,關閉按鈕,拖動手柄等)被添加到您撥打.dialog()
的div的外部。所以#sendInviteRequestDialog .ui-dialog .ui-widget-header
將無法按預期工作。
風格化特定的對話框中,使用dialogClass
選項:
指定的類名(S)將被添加到對話框中, 額外的主題化。
示例代碼:
$("#sendInviteRequestDialog").dialog({
modal: true,
dialogClass: "custom-dialog-1"
});
生成的標記:
<div class="ui-dialog ui-widget ui-widget-content ui-corner-all custom-dialog-1 ui-draggable ui-resizable" tabindex="-1" role="dialog" aria-labelledby="ui-id-1" style="outline: 0px; z-index: 1002; position: absolute; height: auto; width: 300px; top: 29.5px; left: 125.5px; display: block;">
<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix"><span id="ui-id-1" class="ui-dialog-title">Title</span><a href="#" class="ui-dialog-titlebar-close ui-corner-all" role="button"><span class="ui-icon ui-icon-closethick">close</span></a></div>
<div id="sendInviteRequestDialog" class="ui-dialog-content ui-widget-content" scrolltop="0" scrollleft="0" style="width: auto; min-height: 82px; height: auto;">Content</div>
<div class="ui-resizable-handle ui-resizable-n" style="z-index: 1000;"></div>
<div class="ui-resizable-handle ui-resizable-e" style="z-index: 1000;"></div>
<div class="ui-resizable-handle ui-resizable-s" style="z-index: 1000;"></div>
<div class="ui-resizable-handle ui-resizable-w" style="z-index: 1000;"></div>
<div class="ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se ui-icon-grip-diagonal-se" style="z-index: 1000;"></div>
<div class="ui-resizable-handle ui-resizable-sw" style="z-index: 1000;"></div>
<div class="ui-resizable-handle ui-resizable-ne" style="z-index: 1000;"></div>
<div class="ui-resizable-handle ui-resizable-nw" style="z-index: 1000;"></div>
</div>
實施例的CSS:
.custom-dialog-1 .ui-widget-header {
background: green;
}
Demo on jsFiddle
請注意,我用background
快捷鍵代替background-color
;這會重置所有背景屬性,包括背景圖像。標題欄的默認背景色實際上是一個圖像。