extjs - 将formPanel置于普通面板上

Ben*_*Ben 3 extjs centering

我正在使用extjs并试图解决一个简单的问题:我有一个固定宽度的表单.我想将此表单置于普通的Ext.Panel中.我试图实现'css-way' - 将左右边距设置为'auto'.

但这不起作用,似乎边缘被忽略了.

代码:

var curStateForm = new Ext.FormPanel({
    title:'test',
    width:300,
    bodyStyle:'margin:5px auto 0 auto',
    items: [edIst, edAdjust, edSumme]
});   


var testPanel = new Ext.Panel({
    width: '100%',
    frame:true,
    items: [curStateForm]
});  
Run Code Online (Sandbox Code Playgroud)

A1r*_*Pun 17

在Ext 4中,这对我来说非常适合

在任何容器上使用它

    layout: {
        type: 'vbox',
        align: 'center',
        pack: 'center'
    },
    items: [{
        title: 'Centered Panel',
        width: 200,
        height: 200
    }]
Run Code Online (Sandbox Code Playgroud)