有沒有簡單的方法來更改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