extjs - 在一个普通面板上放置一个formPanel [英] extjs - center a formPanel on a normal panel
问题描述
我正在使用extjs,只是想解决一个简单的问题:
我有一个固定宽度的表单。我想在一个普通的Ext.Panel中心这个表单。
我试图实现这个'css-way' - 将左右边距设置为'auto'。
I'm using extjs and just trying to solve a simple problem: I have a form with a fixed width. I want to Center this form within a normal Ext.Panel. I'm trying to achieve this the 'css-way' - setting the left and right margin to '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]
});
推荐答案
你看过此示例?查看自定义布局/中心下的示例。
Have you seen this sample? Look at the example under "custom layouts / center".
编辑:在Ext 3中,该示例是要走的路。现在在Ext 4中,最好使用外部容器上的vbox布局,中心对齐,如 A1rPun的答案所示。
In Ext 3, that sample was the way to go. Now in Ext 4, it would be best to use a vbox layout on the outer container with center alignment as shown in A1rPun's answer.
这篇关于extjs - 在一个普通面板上放置一个formPanel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!