Page 2 of 6

Center grouped buttons on home page (vertical and horizontal alignment)

Posted: Tue Nov 12, 2013 1:58 pm
by Jay6395558

It is not public yet but I published it in Appery. Is that good enough for what you need?

http://mitechnologies.app.appery.io


Center grouped buttons on home page (vertical and horizontal alignment)

Posted: Tue Nov 12, 2013 1:59 pm
by Jay6395558

The grouped buttons I want to center are on the home page.


Center grouped buttons on home page (vertical and horizontal alignment)

Posted: Tue Nov 12, 2013 2:44 pm
by Kateryna Grynko

Hi Jay,

Your button group is named "mobilegroupedbuttons_55" and in code you use "mobilegroupedbuttons".


Center grouped buttons on home page (vertical and horizontal alignment)

Posted: Tue Nov 12, 2013 2:51 pm
by Jay6395558

I originally used that name but it wasn't working. Now it does, however, I don't want the width of the buttons to get smaller. I tried taking your reference to left margin out of the code but now the button size remains small and it is left aligned. See image and code... Image

Code:
bg = Appery("mobilegroupedbuttons_55");
bg.css("position", "absolute");
bg.css("top", "50%");
bg.css("margin-top", -parseInt(bg.css("height"))/2);


Center grouped buttons on home page (vertical and horizontal alignment)

Posted: Tue Nov 12, 2013 3:33 pm
by Kateryna Grynko

Jay,

If you need to align vertically only and leave the screen width, add the following code to the existing:prebg.css("width", "100%");/pre


Center grouped buttons on home page (vertical and horizontal alignment)

Posted: Tue Nov 12, 2013 3:37 pm
by Jay6395558

Now it looks like this. I do not want it right aligned. I still want there to be equal padding on both sides.
Image


Center grouped buttons on home page (vertical and horizontal alignment)

Posted: Wed Nov 13, 2013 11:38 am
by Kateryna Grynko

Hi Jay,

Please also add the following:precodebg.css("left", "0");
bg.css("margin-left", "0");/code/pre


Center grouped buttons on home page (vertical and horizontal alignment)

Posted: Mon Nov 18, 2013 4:47 pm
by Kevin Preston

The solution you gave some time ago to centre buttons was working fine both during test and on the phone, for some reason it has now stopped working properly on either, the button group is pushed too far to the right. The code you gave is :-
bg = Appery("mobilegroupedbuttons");
bg.css("position", "absolute");
bg.css("top", "50%");
bg.css("left", "50%");
bg.css("margin-left", -parseInt(bg.css("width"))/2);
bg.css("margin-top", -parseInt(bg.css("height"))/2);

Why would it have changed? There are no errors.


Center grouped buttons on home page (vertical and horizontal alignment)

Posted: Mon Nov 18, 2013 5:16 pm
by Kevin Preston

I have discovered what was wrong. Originally I was using static values for the button text but have now moved on to dynamic values coming from a service via local storage. I was setting the button value from the 'page show' event, if you set the values from 'page load' instead it works OK. Presumably the values were being calculated from the dimensions before the content was changed in 'page show'.


Center grouped buttons on home page (vertical and horizontal alignment)

Posted: Mon Nov 18, 2013 5:23 pm
by Kateryna Grynko

Hi Kevin,

Thank you for the update! Do you need any further help?