css - How do I center a set of JQuery Mobile radio buttons in the viewport? -


i'm making app using jquery mobile on top of phonegap (cordova). used codiqa come wireframe ui. looks ok far, group of radio buttons i'm going use change views wasn't centred - off left 25px on wvga800-sized webkit browser. when scaled tablet shape, group got further , further centre of viewport.

here's jsfiddle link project problem unfixed - http://jsfiddle.net/jaspermogg/sahxy/1/

here's jsfiddle link project fixed me - http://jsfiddle.net/jaspermogg/nvmsk

i came solution using jquery, i'm inexperienced , don't know event fire on.

when load ui in webkit, renders ui pre-script, before refreshing after <1s post-script state. looks lame. have script set run on $(window).load.

questions:

  1. what event should looking for, , show me how implement that?

  2. is script in right place - should inside page, way is, or outside? or in head even?

  3. it feels stupid doing jq - surely there's way css?

thanks in advance offered! cheers!

i guess answered own question in comments above, gonna formalise accepting answer.

what did in end -

(1) set radio button-containing div visibility: hidden in css.

(2) find widths of each radio button , add them together.

(3) set width of radio button-containing div total width.

(4) chain change of visibility property onto (3).

the css has set -

#viewselector{     margin: 0 auto;     text-align: center;     visibility: hidden; } 

the code (1) (4) follows -

$(document).ready(function(){      var idealwidth = 0      $(".ui-radio").each(function(){         idealwidth = idealwidth + $(this).width();     });      $("#viewselector").width(idealwidth).css('visibility','visible');  }); 

hope helps someone!


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -