监听横屏竖屏


@media all and (orientation: portrait) {
body div {background: red;}
}
@media all and (orientation: landscape) {
body div {background: blue; }
}


function rotate (){
if(document.documentElement.clientWidth > document.documentElement.clientHeight){
window.location.reload()
break
}else{
window.location.reload()
break
}
}
window.onload = rotate;
window.onresize = rotate;

猜你喜欢

转载自www.cnblogs.com/PoisonousMushrooms/p/12361401.html