Align items vertically in a center - Sencha Panel

sohail.hussain.dyn picture sohail.hussain.dyn · Nov 22, 2013 · Viewed 30k times · Source

I am trying to align mid of the screen of an item simply a label but it is aligning it horizontally not vertically.

var panel = new Ext.Panel({
    layout:{
        type: 'vbox',
        align: 'center'
    },
    items:[
        {
            xtype: 'label',
            html: 'My Label'
        }
    ],
    fullscreen: true,
    flex: 1
});

I have removed flex, and set height as well, but it doesn't work. Please give me some clue?

Answer

Sujata Chanda picture Sujata Chanda · Nov 22, 2013

Try using pack: center in the layout, like this:

var panel = new Ext.Panel({
    layout: {
        type: 'hbox',
        align: 'center',
        pack: 'center'
    }, 
    items:[
        {
            xtype: 'label',
            html: 'My Label'
        }
    ]
});