我知道這個主題上有很多帖子,但即使在查看所有內容並試圖使用所有「cls」配置後,我的按鈕的背景顏色也不會改變。ExtJS 6中的按鈕背景顏色不變
這裏是我的代碼:
var miscTools = Ext.create('Ext.panel.Panel', {
title: 'Tools',
id: 'toolsPanel',
bodyPadding: 5,
height: 200,
border: false,
collapsible: false,
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'button',
id: 'colorToolButton',
text: 'Auto color tool',
cls: 'multiColor-btn',
handler: colorWindow
}]
})
CSS:
.multiColor-btn {
background-color: yellow;
}
我在做什麼錯?
真題答案
所以這個問題是從ExtJS的的灰色主題。我需要刪除按鈕的背景圖像以添加背景顏色。感謝@Alexander的回答。
正確的代碼:
.multiColor-btn {
background-image: none !important;
background-color: yellow !important;
}
另一種選擇將是使用「AfterRender階段」事件改變背景顏色。但是,它只會更改文本背景顏色。感謝@nenadg這個答案。
Ext.getCmp('colorToolButton').btnInnerEl.addCls('multiColor-btn')
這個問題必須與您的主題。你使用哪個主題?在triton中,你的代碼適合我。 – Alexander
我使用灰色主題... – kaycee
灰色主題使用背景圖像,它優先於背景顏色。 [嘗試'背景圖像:無!重要;'。](https://fiddle.sencha.com/#fiddle/15vl) – Alexander