我有一个网站,其移动版本使用 jquery mobile。当我将其从纵向更改为横向时,它会正确放大,但当我翻转到纵向时,它会保持相同的缩放级别,并且比视图更宽,这会破坏用户体验。
我使用常规:
<meta name="viewport" content="width=device-width, initial-scale=1">
从我所做的所有搜索来看,这应该可以。不幸的是它不适合我。
这是我的问题,我可以使用 onorientationchange 事件来触发页面大小的调整,我只是不知道如何去做。你能帮忙吗?
附:如果您想看一下,网站就在这里http://tmg.dev.dakic.com/mobile http://tmg.dev.dakic.com/mobile
谢谢你,
泽利科
试试这个,我也有类似的问题:
$(window).bind('orientationchange', function(event) {
if (window.orientation == 90 || window.orientation == -90 || window.orientation == 270) {
$('meta[name="viewport"]').attr('content', 'height=device-width,width=device-height,initial-scale=1.0,maximum-scale=1.0');
$(window).resize();
$('meta[name="viewport"]').attr('content', 'height=device-width,width=device-height,initial-scale=1.0,maximum-scale=2.0');
$(window).resize();
} else {
$('meta[name="viewport"]').attr('content', 'height=device-height,width=device-width,initial-scale=1.0,maximum-scale=1.0');
$(window).resize();
$('meta[name="viewport"]').attr('content', 'height=device-height,width=device-width,initial-scale=1.0,maximum-scale=2.0');
$(window).resize();
}
}).trigger('orientationchange');
在某些事件中尝试使用 resize() 函数:
$(window).resize();
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)