状态竖屏横屏
修改前修改后
解决方法:
function verticaHorizontalScreenChange() {//横屏竖屏切换处理事件函数
if (window.orientation == 90 || window.orientation == -90) { //横屏
htmlFontSizeChange();//横屏的时候更改html的字体大小
} else { //竖屏
window.location.reload();
}
}
function htmlFontSizeChange(){
let w = $(window),
w.width() > w.height()? fontsize = w.height(): fontsize = w.width();
$("html").css('font-size',~~(fontsize *100000/36)/100000+"px");
}
window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", verticalHorizontalChange, false);//监听横屏竖屏切换事件