如何在 jquery ui 中更改对话框标题颜色?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21337182/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I change dialog title color in jquery ui?
提问by milandjukic88
I have something like this:
我有这样的事情:
$div = $('<div id="error" title="Error">');
$div.append('<p>Hi</p>');
$div.dialog({
modal: true,
maxHeight:500,
});
Can i change background color of dialog title somehow like this?:
我可以像这样以某种方式更改对话框标题的背景颜色吗?:
$div.dialog({
modal: true,
maxHeight:500,
}).find(".ui-dialog-titlebar").css("background-color","red");
回答by DaniP
Use prev()
instead of find()
because that element is not inside $div
:
使用prev()
而不是find()
因为该元素不在里面$div
:
$div.dialog({
modal: true,
maxHeight:500,
}).prev(".ui-dialog-titlebar").css("background","red");
Also I use background
to override all other elements like background-image
我也background
用来覆盖所有其他元素,如background-image
Check this http://jsfiddle.net/Ad7nF/
回答by user1428716
Another method to do is to :
另一种方法是:
Define your styling class - myTitleClass
定义您的样式类 - myTitleClass
Define the css as
将 css 定义为
. myTitleClass .ui-dialog-titlebar {
background:red;
}
and add the custom class to the dialog initialization function :
并将自定义类添加到对话框初始化函数:
$( "#dialog" ).dialog({
autoOpen: false,
dialogClass: 'myTitleClass'
});
JSFiddle - (but with another sample code)
JSFiddle - (但有另一个示例代码)
回答by Mikeys4u
Most simple way is this: -
最简单的方法是这样的:-
.ui-dialog-titlebar {
background:red;
}