判断横屏竖屏,然后CSS重新计算

function hengshuping(){
if(window.orientation==180||window.orientation==0){
alert("竖屏状态!")
window.location.reload();

}
if(window.orientation==90||window.orientation==-90){
alert("横屏状态!")
window.location.reload();
}
}
window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", hengshuping, false);

原文地址:https://www.cnblogs.com/binmengxue/p/5614168.html