Jonathan Snook tiene una solución a este problema. En sus diapositivas here, muestra cómo (tipo de) bloquear a retrato (ver diapositiva 54 y 55).
El código JS de las diapositivas:
window.addEventListener('orientationchange', function() {
if (window.orientation == -90) {
document.getElementById('orient').className = 'orientright';
}
if (window.orientation == 90) {
document.getElementById('orient').className = 'orientleft';
}
if (window.orientation == 0) {
document.getElementById('orient').className = '';
}
}, true);
y el CSS:
.orientleft #shell {
-webkit-transform: rotate(-90deg);
-webkit-transform-origin:160px 160px;
}
.orientright #shell {
-webkit-transform: rotate(90deg);
-webkit-transform-origin:230px 230px;
}
Me trataron de conseguir este funcionamiento para paisaje en el iPhone, pero nunca miraron 100 % correcto Sin embargo, me acerqué al siguiente código jQueryian. Esto estaría dentro de la función de listo. También tenga en cuenta: esto fue dentro de un contexto "guardado en pantalla de inicio", y creo que alteró la posición del origen de la transformación.
$(window).bind('orientationchange', function(e, onready){
if(onready){
$(document.body).addClass('portrait-onready');
}
if (Math.abs(window.orientation) != 90){
$(document.body).addClass('portrait');
}
else {
$(document.body).removeClass('portrait').removeClass('portrait-onready');
}
});
$(window).trigger('orientationchange', true); // fire the orientation change event at the start, to make sure
Y el CSS:
.portrait {
-webkit-transform: rotate(90deg);
-webkit-transform-origin: 200px 190px;
}
.portrait-onready {
-webkit-transform: rotate(90deg);
-webkit-transform-origin: 165px 150px;
}
la esperanza de que ayude a alguien acercarse al resultado deseado ...
relacionadas: http://stackoverflow.com/questions/1207008/how-do-i-lock-the-orientation-to-portrait-mode-in-a-iphone-web-application – xdhmoore
Lea la pregunta enlazada por @xdhmoore. Vale la pena además de este. – Boaz