我也有同样的问题,我找到了3种方法来解决它,选择最适合你的方法,我使用第三个版本。抱歉,我的英语不是最好的,我希望它能被理解:(
第一个解决方案:
您可以添加自定义 css 条目。它可以解决问题,但如果您更改主题,则可能会出错。
.x-form-field-container {
background: white;
}
第二个解决方案:
您可以使用溢出隐藏,但在这种情况下,末尾的文本将被剪切。
.x-form-label {
overflow: hidden;
}
.x-form-label span
{
white-space: nowrap;
}
第三个解决方案:
您可以在字段前使用 100% 宽度的标签。在这种情况下,输入字段的宽度也将是 100%。
new Ext.form.FormPanel({
title: 'Form name',
scroll: 'vertical',
items: [{
xtype: 'fieldset',
title: 'Fieldset title',
items: [{
xtype: 'field',
html: '<div class="x-form-label" style="width:100%"><span>This is the label of the field in below</span></div>'
},{
xtype: 'selectfield',
name: 'nameOfTheField'
//without label attribute
}]
}]
});
EDIT
by rockinthesixstring
这是我为了达到相同结果而进行的修改。
CSS
.x-checkbox{ background:white;}
JS
{
xtype: 'checkboxfield',
name: 'updateinfo',
label: 'Update my info',
labelWidth: '80%',
cls: "x-checkbox"
}