如何使用ExtJS更改文本字段的颜色? [英] How do I change color of a textfield using ExtJS?

查看:648
本文介绍了如何使用ExtJS更改文本字段的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想改变ExtJS文本字段的颜色,但是我没有成功。标签是获取颜色的组件:

I would like to change the color of a ExtJS textfield, but I don´t succeed. The label is the component that gets the color:

var textfield= Ext.create('Ext.form.Text', 
    {
        id: 'textfield',
        name: 'name',
        fieldLabel: 'Name',
        style: 'background-color: #ddd;',
        allowBlank: false,
    });

Ext.create('Ext.form.Panel', {
    title: 'Contact Info',
    width: 300,
    bodyPadding: 10,
    renderTo: Ext.getBody(),
    items: [textfield]
});

示例:
http://jsfiddle.net/3ZZcZ/

如何更改颜色?

推荐答案

您需要设置 fieldStyle 而不是 style 。您还需要覆盖Ext JS默认设置,该默认设置在该字段上设置一个背景图像。像这样:

You need to set fieldStyle instead of style. You also need to override the Ext JS default, which sets a background image on the field. Like this:

fieldStyle: 'background-color: #ddd; background-image: none;'

这篇关于如何使用ExtJS更改文本字段的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆