修改以下css選擇器。
.hello-world {
white-space: normal;
text-align: justify;
margin: -10px 0 0 10px;
}
那麼,試試這個。
Ext.require(['*']);
Ext.onReady(function() {
var viewport = Ext.create('Ext.Viewport', {
layout: {
type: 'border',
padding: 5
},
defaults: {
split: true
},
items: [{
region: 'west',
collapsible: true,
header: false,
split: true,
width: 200,
items: [{
xtype: 'checkboxgroup',
columns: 1,
vertical: true,
id: 'cb-group',
items: [{
boxLabel: 'Item 1',
name: 'rb',
inputValue: '1'
}, {
boxLabel: 'Item 2 with large box label does not wrap properly',
name: 'rb',
inputValue: '2',
checked: true
}, {
boxLabel: 'Item 3',
name: 'rb',
inputValue: '3'
}, {
boxLabel: 'Item 4',
name: 'rb',
inputValue: '4'
}, {
boxLabel: 'Item 5',
name: 'rb',
inputValue: '5'
}, {
boxLabel: 'Item 6',
name: 'rb',
inputValue: '6'
}],
listeners: {
beforerender: function() {
for (var i = 1; i < Ext.getCmp('cb-group').items.length; i++) {
if (Ext.getCmp('cb-group').items.items[i].boxLabel.length > 24) {
Ext.getCmp('cb-group').items.items[i].boxLabelCls = "hello-world";
}
}
}
}
}]
}, {
region: 'center',
html: 'center',
title: 'Center'
}, {
region: 'south',
title: 'South',
height: 100,
split: true,
collapsible: true,
html: 'south'
}]
});
});
我張貼的答案,類似(但不同)的問題在這裏http://stackoverflow.com/a/35432681/1385429。我在這裏發佈了答案。這是一個重複的答案,因此版主刪除了它。理所當然地。不幸的是,他選擇刪除這個問題的答案。在其他問題刪除它會更合適。哦,好吧...... –