A quick, dirty fix would probably be to execute a method to reset the margins when the onorientationchange
event is triggered on the body
.
So example code would be as follows:
<body onorientationchange= "fixMargins()">
....
function fixMargins() {
var orientation = window.orientation;
switch (orientation) {
case 0: // portrait
$('div').css('margin-right', '40px');
break;
case 90: // landscape left
$('div').css('margin-right', '40px');
break;
case -90: //landscape right
$('div').css('margin-right', '40px');
break;
case 180: // portrait upside down
$('div').css('margin-right', '40px');
break;
}
}
Obviously this is not ideal and you would prefer an explanation for why this happens. But I just thought I'd suggest this as a quick fix