我的页面在横向模式下工作正常但在纵向模式下我需要缩小一点然后它适合屏幕。所以我想编写一个JavaScript,当我以纵向模式旋转时缩小或缩小我的页面
if(navigator.platform == 'iPad') {
window.onorientationchange = function () {
var orientation = window.orientation;
// Look at the value of window.orientation:
if (orientation === 0) {
alert("iPad is in Portrait mode.");
// my code goes here
var viewportmeta = document.querySelector('meta[name="viewport"]');
viewportmeta.content = 'width = 1003,initial-scale = 0.5, maximum-scale = 2.0, minimum-scale=0.7';
}
else if (orientation === 90) {
// iPad is in Landscape mode. The screen is turned to the left.
}
else if (orientation === -90) {
// iPad is in Landscape mode. The screen is turned to the right.
}
}
}
在scale = 0.5;
答案 0 :(得分:0)
我刚用<meta name="viewport" content="width=640">
并且每一个都解决了