-
23 Sep 2010 5:06 PM #1
Set a image in middle and center in a Container
Set a image in middle and center in a Container
Hi there,
Would you please tell me on how to load a image and set it to 'middle' and 'center'. I was able to load it into container but couldn't position it in middle' and 'center'.
thank youCode:var c = new Ext.Container({ layout:{ type:'vbox', align:'middle' }, width:500, height:400, html:'<img src="http://www.google.com/images/logos/ps_logo2.png"/>' })
-
23 Sep 2010 10:00 PM #2
add hidden class on your img and show it only after alignTo calledCode:var c = new Ext.Container({ id: 'mycontainer', layout: { type: 'vbox', align: 'middle' }, listeners: { 'afterlayout': function () { Ext.get('myimg').alignTo('mycontainer', 'c-c'); } } width: 500, height: 400, html: '<img id="myimg" src="http://www.google.com/images/logos/ps_logo2.png"/>' })
-
24 Sep 2010 7:37 AM #3
laurentParis, thanks for your input. It works great, and I love EXTJS!
I have one more question on this, I need to add an event to check the image state as well before calling alignTo method, otherwise the image won't properly be set in the container.
for exmple: if the image is successfully loaded then call something like this...
is it possible doing this in ExtJS? thanks
Code:listeners : { afterrender : function() { Ext.get('myimg').addListener('complete', function(){ Ext.get('myimg').alignTo('mycontainer', 'c-c'); }); } }
Similar Threads
-
how to set 'alt' attribute for the image setting for an image button
By Sriman in forum Ext GWT: DiscussionReplies: 1Last Post: 16 Nov 2011, 1:53 PM -
How to set the image of rowAction to the Center?
By yagi in forum Ext 2.x: Help & DiscussionReplies: 3Last Post: 3 Aug 2010, 12:20 AM -
[UNKNOWN][3.0.0] BoxLayout bugs when align is 'middle' and flex is set
By warbaby in forum Ext 3.x: BugsReplies: 1Last Post: 20 Nov 2009, 2:22 AM -
[SOLVED]Can I center an image in a panel?
By StevenInc in forum Ext 3.x: Help & DiscussionReplies: 2Last Post: 10 Aug 2009, 7:18 PM -
How to center the image in ContentPanel?
By andre_guitar7 in forum Ext 2.x: Help & DiscussionReplies: 0Last Post: 30 Mar 2009, 5:01 AM


Reply With Quote