我被一些我想象中会很安静的事情困住了:)
将两个面板放在一起,并保持它们的中心位置。我得到的最接近的方法是在面板中间,但在另一个面板上。
就像这样:
_
|_|
_
|_|我在试着
_ _
|_| |_|到目前为止这是我的档案
Ext.define("App.view.MyWindow", {
extend:'Ext.panel.Panel',
alias:'widget.mywindow',
requires:[
//this is just a simply panel with html:'abcde"
'App.view.Portal1'
],
items:[{
xtype:'portal1',
height:400,
width:400,
style:{
margin: '0 auto',
}
},{
xtype:'portal1',
height:400,
width:400,
style:{
margin: '0 auto',
}
}]
});有什么想法吗?欢迎大家:)提前感谢
更新:最接近“解决方案”的是:(但是它需要一个设置的宽度)
Ext.define("App.view.MyWindow", {
extend:'Ext.panel.Panel',
alias:'widget.mywindow',
requires:[
//this is just a simply panel with html:'abcde" with width & height 400
'App.view.Portal1'
],
layout:'fit',
items:[{
layout:{
type:'vbox',
align:'center'
},
items:[{
layout:{
type:'hbox',
},
//Set width :(
width:800,
items:[{
xtype:'portal1',
},{
xtype:'portal1',
}]
}]
}]
});溶液
感谢那些发表评论的人。这是一个可行的解决方案。不要在包装面板上使用layout:fit
Ext.define("App.view.MyWindow", {
extend:'Ext.panel.Panel',
alias:'widget.mywindow',
requires:[
//this is just a simply panel with html:'abcde" with width & height 400
'App.view.Portal1'
],
style:{
textAlign:'center'
},
items:[{
xtype:'portal1',
style:{
display:'inline-block'
}
},{
xtype:'portal1',
style:{
display:'inline-block'
}
}]
});发布于 2012-02-16 16:03:15
CSS唯一的解决方案,因为我不知道extjs:
给每个面板适当的水平边距,这样它们就不会一起运行。将它们的宽度和高度设置为正常。然后在面板上设置display: inline。最后,将包含元素设置为使用text-align: center。为此您可能需要引入一个新的容器元素。
发布于 2012-02-16 15:58:32
给“myWindow”一个hbox布局。包含在其中的项目将被水平地布局。
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.layout.container.HBox
https://stackoverflow.com/questions/9313734
复制相似问题