如何让这三个按钮在容器内居中均匀分布?

时间:2011-10-20 00:26:49

标签: sencha-touch sencha-touch-2

只是想知道是否有人可以让我知道如何让这三个按钮在容器内居中均匀分布?

Ext.define('rpc.view.home.indexView', {
    extend: 'Ext.Panel',
    alias: 'widget.homeView',
    config: {
       items: [{
           xtype: 'panel',
           layout: { 
               type: 'vbox',
               pack: 'center'
           },
           defaults: {
               xtype: 'button',
               margin: '10 10 0 10'
           },
           items: [{
               text: 'Videos',
               cls: 'x-button-quicknav'
           }, {
               text: 'Events',
               cls: 'x-button-quicknav'
           }, {
               text: 'Sites',
               cls: 'x-button-quicknav'
           }]
        }]
    },
    initialize: function () {
        console.log('rpc.view.home.index ~ initialize');
    }
});

1 个答案:

答案 0 :(得分:2)

Nailed it

JS

xtype: 'container',
       layout: {
           type: 'hbox',
           pack: 'center'
       },
       defaults: {
           xtype: 'button',
           ui: 'plain',
           style: 'margin-top: 5px;'
       },
       items: [{
           text: 'Videos',
           cls: 'x-button-rpc',
           flex: 1
       }, {
           xtype: 'container',
           cls: 'x-button-rpc-spacer'
       }, {
           text: 'Events',
           cls: 'x-button-rpc',
           flex: 1
       }, {
           xtype: 'container',
           cls: 'x-button-rpc-spacer'
       }, {
           text: 'Sites',
           cls: 'x-button-rpc',
           flex: 1
       }]

CSS

.x-button-rpc{
    border-radius: 5px;
    border:1px solid #c4c4c4 !important;
    background-color: White !important;
}

.x-button-rpc-spacer{
    display: inline-block;
    width: 5px;
}