Look in the user agent string, and then set them accordingly.
I'd do it like...
JavaScript / jQuery
if (navigator.userAgent.match(/iPhone/)) {
$('body').addClass('iphone');
} else if (navigator.userAgent.match(/iPad/)) {
$('body').addClass('ipad');
}
If you are using jQuery only for this, you could cut down on some bloat by replacing those addClass()
lines with...
var body = document.getElementsByTagName('body')[0];
body.className = body.className + ' iphone';
...or to make sure it always looks pretty in the source...
var body = document.getElementsByTagName('body')[0];
var bodyClasses = body.className.split(' ');
bodyClasses.push('iphone');
body.className = bodyClasses.join(' ');
Check it out.
CSS
.ipad #nav button {
width: 150px;
height: 150px;
}
.iphone #nav button {
width: 75px;
height: 75px;
}
This is assuming your buttons will scale by default in the browser - if you have two different images, you could change the background-image
CSS property.