有没有办法让移动网站在移动设备上保持横向模式?
我们可以使用任何JavaScript代码吗?
答案 0 :(得分:0)
限制用户可能会破坏用户exp,如果您确定它不会破坏该代码的经验--->
//this function will rotate you screen(cross browser!!!)
function rotate(el, degs) {
iedegs = degs/90;
if (iedegs < 0) iedegs += 4);
transform = 'rotate('+degs+'deg)';
iefilter = 'progid:DXImageTransform.Microsoft.BasicImage(rotation='+iedegs+')';
styles = {
transform: transform,
'-webkit-transform': transform,
'-moz-transform': transform,
'-o-transform': transform,
filter: iefilter,
'-ms-filter': iefilter
};
$(el).css(styles);
}
//this will check your orientation and then take action as you desrired!!!
$(window).bind('orientationchange resize', function(event){
if(event.orientation) {
if (event.orientation == 'landscape') {
if (window.rotation == 90) {
rotate(this, -90);
} else {
rotate(this, 90);
}
}
});