Como posso obter estes três botões para centrado e uniformemente espaçados dentro do recipiente?

StackOverflow https://stackoverflow.com/questions/7829796

  •  27-10-2019
  •  | 
  •  

Pergunta

Basta saber se alguém pode me dizer como posso obter estes três botões para centrado e uniformemente espaçados dentro do recipiente?

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');
    }
});
Foi útil?

Solução

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;
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top