[英]ExtJS how to set button css by using pressedCls config
I want to change color when button is pressed. 我想在按下按钮时更改颜色。 I tried to use pressedCls config but it didn't work.
我试图使用pressedCls配置,但是没有用。 How to fix the problem or is there another way to set css when button is pressed?
如何解决该问题,或者在按下按钮时还有另一种设置CSS的方法? Thanks a lot!
非常感谢!
Javascript: Javascript:
Ext.create('Ext.Button', {
text: 'Click me',
renderTo: Ext.getBody(),
cls: 'my-btn',
pressedCls: 'my-btn-pressed'
});
CSS: CSS:
.my-btn {
background: Black
}
.my-btn-pressed {
background: Red;
}
I think this is a bug, for 4 ext you just can add "x-"-prefix for your pressedCls. 我认为这是一个错误,对于4分机,您只需为pressedCls添加“ x-”前缀即可。 But for extjs 5 you must use !important directive in your css attribute. 但是对于extjs 5,必须在css属性中使用!important指令。 Look at this: 看这个:
Edited Thanks for @Digigizmo For ExtJs 5 you need to use correct element selector. 编辑感谢@Digigizmo对于ExtJs 5,您需要使用正确的元素选择器。 For 4 version and earlier just add "x-" prefix for css attribute.
对于4版本或更早的版本,只需为CSS属性添加“ x-”前缀。
.my-btn.x-btn.x-btn-pressed {
background: Red;
}
For ExtJs 4 and earlier 对于ExtJs 4和更早版本
.x-my-btn-pressed {
background: Red;
}
For ExtJs 5 (wrong way, use correct selector above) 对于ExtJs 5(错误的方法,使用上面的正确选择器)
.x-btn-pressed.my-btn {
background: Red !important;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.