有没有简单的方法来更改jQuery UI按钮的颜色?从文档中修改css是不鼓励的,反正这样做是棘手的。他们说,“我们建议使用ThemeRoller工具来创建和下载易于构建和维护的自定义主题。”我了解如何更改主题,但是如何在同一页上获得不同颜色的按钮?更改jQuery UI按钮的颜色
28
A
回答
16
我只是这样做:创建新的颜色按钮,一个新的主题;复制新主题图像文件夹中的..hard ..和..soft ...渐变文件;重新命名它们以免它们与主题混淆;最后将样式添加到按钮。这迎合了梯度和颜色...
我只是尝试这样做的一个绿色按钮:
a.green-button
{
background: url(Images/GreenBGHardGrad.png) repeat-x center;
border: 1px solid #132b14;
color:#FFFFFF;
}
a.green-button:hover
{
background: url(Images/GreenBGSoftGrad.png) repeat-x center;
border: 1px solid #132b14;
color:#FFFFFF;
}
a.green-button:active
{
background-color:#FFFFFF;
border: 1px solid #132b14;
color:#132b14;
}
8
最简单的方法是向你的按钮添加一个类(用于不同的颜色),然后用一些css来覆盖jquery-ui css。
例
var $button = $(document.createElement('a'));
//add class
$button.addClass('redButton');
//call the jquery-ui button function
$button.button();
的CSS
.ui-button.redButton {
background-color: red;
}
.ui-button.greenButton {
background-color: green;
}
2
试试这个:
HTML:
<button type="button" id="change_color"> change button </button>
jQuery:
$("#change_color").css("background","green");
0
有两种(三种)JQueryUI按钮类型;基本上你做一个button这样的:
<span class="myButtons">Click here</span>
那你告诉jQueryUI的,这是一个按钮:
$('span.myButtons').button()
因此生产这种标记:
<span class="myButtons ui-button ui-corner-all ui-widget" role="button">Click here</span>
你可以风格这个“经典“方式:(.myButtons {}
,.myButtons:hover {}
等)
但是!
如果你的 “按钮” 是checkboxradio一个或controlgroup那么它的另一标记:
<fieldset>
<legend>Select a Location: </legend>
<label for="radio-1">New York</label>
<input type="radio" name="radio-1" id="radio-1">
<label class"danger" for="radio-2">Paris</label>
<input type="radio" name="radio-1" id="radio-2">
<label for="radio-3">London</label>
<input type="radio" name="radio-1" id="radio-3">
</fieldset>
然后,如果你申请的方法:
$("input").checkboxradio();
你得到这个生成的标记(在第二个伪按钮,“巴黎”被检查/点击):
<fieldset>
<legend>Select a Location: </legend>
<label for="radio-1" class="ui-checkboxradio-label ui-corner-all ui-button ui-widget ui-checkboxradio-radio-label"><span class="ui-checkboxradio-icon ui-corner-all ui-icon ui-icon-background ui-icon-blank"></span><span class="ui-checkboxradio-icon-space"> </span>New York</label>
<input name="radio-1" id="radio-1" class="ui-checkboxradio ui-helper-hidden-accessible" type="radio">
<label for="radio-2" class="ui-checkboxradio-label ui-corner-all ui-button ui-widget ui-checkboxradio-radio-label ui-checkboxradio-checked ui-state-active"><span class="ui-checkboxradio-icon ui-corner-all ui-icon ui-icon-background ui-icon-blank"></span><span class="ui-checkboxradio-icon-space"> </span>Paris</label>
<input name="radio-1" id="radio-2" class="ui-checkboxradio ui-helper-hidden-accessible" type="radio">
<label for="radio-3" class="ui-checkboxradio-label ui-corner-all ui-button ui-widget ui-checkboxradio-radio-label"><span class="ui-checkboxradio-icon ui-corner-all ui-icon ui-icon-background ui-icon-blank"></span><span class="ui-checkboxradio-icon-space"> </span>London</label>
<input name="radio-1" id="radio-3" class="ui-checkboxradio ui-helper-hidden-accessible" type="radio">
</fieldset>
然后those classes可以(必须?)被用于设计伪“按钮”:
.ui-visual-focus {
box-shadow: none;
}
label.ui-checkboxradio.ui-state-default {
color: black;
background-color: teal;
}
label.ui-checkboxradio.danger.ui-state-active {
background-color: red;
}
相关问题
- 1. jQuery UI - 更改按钮颜色
- 2. 更改颜色kendo ui按钮
- 3. 更改jquery-ui按钮的背景颜色?
- 4. 更改颜色的按钮
- 5. IBAction按钮更改颜色?
- 6. 更改按钮颜色
- 7. 按钮更改颜色
- 8. 更改按钮颜色
- 9. 更改AlertDialog.Builder按钮颜色
- 10. 更改radcombobox按钮颜色
- 11. 更改按钮颜色onClick
- 12. 更改TextView按下按钮的颜色
- 13. JQuery UI - 更改按钮类
- 14. 更改按钮颜色作为背景颜色更改?
- 15. 通过脚本更改UI按钮的颜色
- 16. 通过更改按钮样式更改按钮颜色
- 17. 使用jquery ui更改标签颜色?
- 18. 更改Bokeh按钮的颜色?
- 19. 更改按钮的颜色Extjs 3.4
- 20. 更改提交按钮的颜色
- 21. 如何更改按钮的tabcontrol颜色?
- 22. 更改引导按钮的颜色
- 23. C#更改按钮的背景颜色
- 24. 更改AlertDialog中的按钮颜色
- 25. 更改tkinter中按钮的颜色
- 26. 如何更改gridView的按钮颜色
- 27. 更改点击按钮的颜色
- 28. 更改UINavigationController后退按钮的颜色
- 29. 更改关闭按钮的颜色
- 30. SweetAlert - 更改颜色的按钮
背景色设置为红色并没有真正改变按钮颜色 – 2010-12-08 23:02:59
按钮背景是图片,而不是简单的颜色,你需要改变`背景图像“,并可能添加”!重要“来强制该问题。 – 2010-12-09 05:15:44