我需要将3个元素置于页面中心的对方之下。这与HBOX不存在问题。但我的元素有不同的宽度: 两个宽度为350的元素和一个宽度为1000的元素。这里是样本:HBOX布局中的元素对齐extjs 4
Ext.create('Ext.Viewport', {
layout: {
type: "hbox",
pack: "center",
align: "middle"
},
items: {
xtype: 'container',
items:[{
xtype: 'image',
height: 350,
width: 350,
src: '/images/logo.jpg'
},{
xtype: 'image',
height: 350,
width: 350,
src: '/images/logo2.jpg'
},{
xtype: 'panel',
width: 1000,
margin: '0px 0px 0px -325px',
frame: true,
autoscroll: true,
title: 'panel title',
html: 'some panel with some rows with<br /> some text'
}]
},
renderTo: Ext.getBody()
});
主要问题是元素的水平排列。 第二个问题是:如果屏幕的分辨率很小,没有滚动条,并且面板中有大文本。
好的,又如:
Ext.create('Ext.Viewport', {
layout: {
type: "hbox",
pack: "center",
align: "middle"
},
items: {
xtype: 'container',
items:[{
xtype: 'form',
width: 350,
title: 'Form Panel',
items: [{
xtype: 'textfield',
fieldLabel: 'Name'
}]
},{
xtype: 'panel',
width: 1000,
frame: true,
autoscroll: true,
title: 'panel title',
html: 'some panel with some rows with<br /> some text'
}]
},
renderTo: Ext.getBody()
});
该面板将是完全在屏幕的中间,但形式不会。 P.S.我试图将布局移动到容器 - 它不起作用
你能否以适当的宽度更新你的代码示例?你也试图使用vbox或hbox? – sha
对不起,我很着急。这段代码是我的代码,所以我使用HBOX和mi width 350px和1000px –
再次请更正您的问题 - 您在标题和标签中包含VBOX,但代码中包含HBOX。您也谈论宽度,但在代码中有高度 – sha