简体   繁体   English

ExtJS 6中的按钮背景颜色不变

[英]Button background color in ExtJS 6 does not change

I know that there is many post on this subject, but even after looking at all and trying to use all the "cls" configs, the background color of my button does not change. 我知道有很多关于此主题的文章,但是即使查看并尝试使用所有“ cls”配置,我的按钮的背景色也不会改变。

Here's my code: 这是我的代码:

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: CSS:

.multiColor-btn {
    background-color: yellow;
}

What am I doing wrong ? 我究竟做错了什么 ?

ANSWERS 答案

So the problem was from the gray theme of ExtJS. 因此问题出在ExtJS的灰色主题上。 I needed to remove the background-image of the button in order to add a background color. 我需要删除按钮的背景图像以添加背景色。 Thanks to @Alexander for his answer. 感谢@Alexander的回答。

Correct code: 正确的代码:

.multiColor-btn {
    background-image: none !important;
    background-color: yellow !important;
}

Another option would have been to use a "afterRender" event to change the background color. 另一个选择是使用“ afterRender”事件来更改背景颜色。 However, it does just change the text background color. 但是,它只会更改文本背景颜色。 Thanks to @nenadg for this answer. 感谢@nenadg提供的答案。

Ext.getCmp('colorToolButton').btnInnerEl.addCls('multiColor-btn')

Try this : 尝试这个 :

.multiColor-btn {
    background-color: yellow !important;
}

Instead of cls, try using userCls property for additional styles. 代替cls,尝试将userCls属性用于其他样式。

http://staging.sencha.com/extjs/6.0/6.0.1-modern/#!/api/Ext.Component-cfg-userCls http://staging.sencha.com/extjs/6.0/6.0.1-modern/#!/api/Ext.Component-cfg-userCls

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM